質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Q&A

解決済

1回答

1466閲覧

google_drive gemでファイルの作成ができない

d04062

総合スコア111

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

0グッド

0クリップ

投稿2021/04/01 15:26

編集2021/04/01 15:41

Rubyでgoogle_drive gemを使用し、
スプレッドシートの作成や、スプレッドシートへの書き込みをしています。

何故か、開発用CentOS7でのみスプレッドシートの作成ができません。

・スプレッドシートへの書き込みは可能です
・他のCentOSでは、作成も書き込みも可能です。

ruby

1require "google_drive" 2 3session = GoogleDrive::Session.from_config("config/GoogleDrive_config.json") 4 5p session 6 7session.create_spreadsheet("My sheet")

sessionの中身は下記のように空ではないようです。

$ ruby rb/test8_sheet.rb #<GoogleDrive::Session:0x21c> Traceback (most recent call last): 22: from rb/test8_sheet.rb:7:in `<main>' 21: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google_drive-3.0.6/lib/google_drive/session.rb:493:in `create_spreadsheet' 20: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google_drive-3.0.6/lib/google_drive/session.rb:510:in `create_file' 19: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-api-client-0.53.0/generated/google/apis/drive_v3/service.rb:918:in `create_file' 18: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-apis-core-0.3.0/lib/google/apis/core/base_service.rb:377:in `execute_or_queue_command' 17: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-apis-core-0.3.0/lib/google/apis/core/http_command.rb:99:in `execute' 16: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/google-apis-core-0.3.0/lib/google/apis/core/api_command.rb:81:in `prepare!' 15: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/json.rb:44:in `to_json' 14: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/hash.rb:34:in `to_hash' 13: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:45:in `create_representation_with' 12: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:70:in `representable_map!' 11: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:51:in `call' 10: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:51:in `each' 9: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable.rb:53:in `block in call' 8: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/binding.rb:32:in `compile_fragment' 7: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:9:in `call' 6: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:9:in `inject' 5: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:9:in `each' 4: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:10:in `block in call' 3: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:18:in `evaluate' 2: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:47:in `call' 1: from /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:47:in `tap' /home/user1/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/representable-3.0.4/lib/representable/pipeline.rb:48:in `block in call': undefined method `each' for nil:NilClass (NoMethodError)

Gemfile

1source 'https://rubygems.org' 2 3ruby "2.7.2" 4gem 'google_drive' 5gem "selenium-webdriver" 6# gem 'webdrivers' 7gem "platform-api" 8 9gem 'rainbow' 10gem 'dotenv-rails' 11gem 'nokogiri', '>= 1.5.3', '<2.0.0' 12gem 'parallel' 13

Gemfile.lock

1GEM 2 remote: https://rubygems.org/ 3 specs: 4 actionpack (6.1.3) 5 actionview (= 6.1.3) 6 activesupport (= 6.1.3) 7 rack (~> 2.0, >= 2.0.9) 8 rack-test (>= 0.6.3) 9 rails-dom-testing (~> 2.0) 10 rails-html-sanitizer (~> 1.0, >= 1.2.0) 11 actionview (6.1.3) 12 activesupport (= 6.1.3) 13 builder (~> 3.1) 14 erubi (~> 1.4) 15 rails-dom-testing (~> 2.0) 16 rails-html-sanitizer (~> 1.1, >= 1.2.0) 17 activesupport (6.1.3) 18 concurrent-ruby (~> 1.0, >= 1.0.2) 19 i18n (>= 1.6, < 2) 20 minitest (>= 5.1) 21 tzinfo (~> 2.0) 22 zeitwerk (~> 2.3) 23 addressable (2.7.0) 24 public_suffix (>= 2.0.2, < 5.0) 25 builder (3.2.4) 26 childprocess (3.0.0) 27 concurrent-ruby (1.1.8) 28 crass (1.0.6) 29 declarative (0.0.20) 30 declarative-option (0.1.0) 31 dotenv (2.7.6) 32 dotenv-rails (2.7.6) 33 dotenv (= 2.7.6) 34 railties (>= 3.2) 35 erubi (1.10.0) 36 erubis (2.7.0) 37 excon (0.79.0) 38 faraday (1.3.0) 39 faraday-net_http (~> 1.0) 40 multipart-post (>= 1.2, < 3) 41 ruby2_keywords 42 faraday-net_http (1.0.1) 43 gems (1.2.0) 44 google-api-client (0.53.0) 45 google-apis-core (~> 0.1) 46 google-apis-generator (~> 0.1) 47 google-apis-core (0.3.0) 48 addressable (~> 2.5, >= 2.5.1) 49 googleauth (~> 0.14) 50 httpclient (>= 2.8.1, < 3.0) 51 mini_mime (~> 1.0) 52 representable (~> 3.0) 53 retriable (>= 2.0, < 4.0) 54 rexml 55 signet (~> 0.14) 56 webrick 57 google-apis-discovery_v1 (0.2.0) 58 google-apis-core (~> 0.1) 59 google-apis-generator (0.2.0) 60 activesupport (>= 5.0) 61 gems (~> 1.2) 62 google-apis-core (~> 0.1) 63 google-apis-discovery_v1 (~> 0.0) 64 thor (>= 0.20, < 2.a) 65 google_drive (3.0.6) 66 google-api-client (>= 0.11.0, < 1.0.0) 67 googleauth (>= 0.5.0, < 1.0.0) 68 nokogiri (>= 1.5.3, < 2.0.0) 69 googleauth (0.16.0) 70 faraday (>= 0.17.3, < 2.0) 71 jwt (>= 1.4, < 3.0) 72 memoist (~> 0.16) 73 multi_json (~> 1.11) 74 os (>= 0.9, < 2.0) 75 signet (~> 0.14) 76 heroics (0.1.2) 77 erubis (~> 2.0) 78 excon 79 moneta 80 multi_json (>= 1.9.2) 81 webrick 82 httpclient (2.8.3) 83 i18n (1.8.9) 84 concurrent-ruby (~> 1.0) 85 jwt (2.2.2) 86 loofah (2.9.0) 87 crass (~> 1.0.2) 88 nokogiri (>= 1.5.9) 89 memoist (0.16.2) 90 method_source (1.0.0) 91 mini_mime (1.0.2) 92 minitest (5.14.4) 93 moneta (1.0.0) 94 multi_json (1.15.0) 95 multipart-post (2.1.1) 96 nokogiri (1.11.2-x86_64-linux) 97 racc (~> 1.4) 98 os (1.1.1) 99 parallel (1.20.1) 100 platform-api (3.3.0) 101 heroics (~> 0.1.1) 102 moneta (~> 1.0.0) 103 rate_throttle_client (~> 0.1.0) 104 public_suffix (4.0.6) 105 racc (1.5.2) 106 rack (2.2.3) 107 rack-test (1.1.0) 108 rack (>= 1.0, < 3) 109 rails-dom-testing (2.0.3) 110 activesupport (>= 4.2.0) 111 nokogiri (>= 1.6) 112 rails-html-sanitizer (1.3.0) 113 loofah (~> 2.3) 114 railties (6.1.3) 115 actionpack (= 6.1.3) 116 activesupport (= 6.1.3) 117 method_source 118 rake (>= 0.8.7) 119 thor (~> 1.0) 120 rainbow (3.0.0) 121 rake (13.0.3) 122 rate_throttle_client (0.1.2) 123 representable (3.0.4) 124 declarative (< 0.1.0) 125 declarative-option (< 0.2.0) 126 uber (< 0.2.0) 127 retriable (3.1.2) 128 rexml (3.2.4) 129 ruby2_keywords (0.0.4) 130 rubyzip (2.3.0) 131 selenium-webdriver (3.142.7) 132 childprocess (>= 0.5, < 4.0) 133 rubyzip (>= 1.2.2) 134 signet (0.15.0) 135 addressable (~> 2.3) 136 faraday (>= 0.17.3, < 2.0) 137 jwt (>= 1.5, < 3.0) 138 multi_json (~> 1.10) 139 thor (1.1.0) 140 tzinfo (2.0.4) 141 concurrent-ruby (~> 1.0) 142 uber (0.1.0) 143 webrick (1.7.0) 144 zeitwerk (2.4.2) 145 146PLATFORMS 147 x86_64-linux 148 149DEPENDENCIES 150 dotenv-rails 151 google_drive 152 nokogiri (>= 1.5.3, < 2.0.0) 153 parallel 154 platform-api 155 rainbow 156 selenium-webdriver 157 158RUBY VERSION 159 ruby 2.7.2p137 160 161BUNDLED WITH 162 2.2.14 163

Google drive関係のGemのバージョンは共通でした

$ gem search google_drive *** REMOTE GEMS *** activestorage_google_drive (0.1.1) carrierwave-google_drive (0.0.2) fastlane-plugin-google_drive (0.6.0) google_drive (3.0.6) google_drive-persistent_session (0.1.3) google_drive_companion (0.1.0) google_drive_dotenv (0.4.0) google_drive_handler (0.1.0) google_drive_oauth (1.0.1) google_driver (0.0.3) middleman-google_drive (0.3.13) parallel588_google_drive (0.3.4) shrine-google_drive_storage (0.4.4) simple_google_drive (0.5.1) tumugi-plugin-google_drive (0.4.0)

環境差異というほどの物が何なのか見当たらない状態です。
何が考えられるでしょうか?
アドバイスいただけますと幸いです。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

Ruby2.5.3にすることで利用可能になりました。

投稿2021/04/03 04:28

d04062

総合スコア111

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問