Closed tbpg closed 3 years ago
@tbpg I think the firestore gem doesn't work with Ruby 2.6 right now.
I followed the instructions for the "add-data" how-to guide on the website (https://cloud.google.com/firestore/docs/manage-data/add-data), meaning creating a new directory with a new Gemfile
which contained the following:
source 'https://rubygems.org'
gem 'google-cloud-firestore'
I made an app.rb
file which contained the following:
require "google/cloud/firestore"
GCP_PROJECT_ID = 'REDACTED'
firestore = Google::Cloud::Firestore.new project_id: GCP_PROJECT_ID
puts "Created Cloud Firestore client with project ID #{GCP_PROJECT_ID} ."
doc_ref = firestore.doc "users/alovelace"
doc_ref.set({
first: "Ada",
last: "Lovelace",
born: 1815
})
puts "Added data to the alovelace document in the users collection."
I also used export GOOGLE_APPLICATION_CREDENTIALS="path_to_file"
to set the service account file before attempting to run the program.
But, when I run bundle install
and then bundle exec ruby app.rb
, I get the following error:
Traceback (most recent call last):
23: from app.rb:1:in `<main>'
22: from app.rb:1:in `require'
21: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore.rb:17:in `<top (required)>'
20: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore.rb:17:in `require'
19: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/client.rb:16:in `<top (required)>'
18: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/client.rb:16:in `require'
17: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1.rb:16:in `<top (required)>'
16: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1.rb:16:in `require'
15: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1/firestore_client.rb:26:in `<top (required)>'
14: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1/firestore_client.rb:26:in `require'
13: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax.rb:30:in `<top (required)>'
12: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax.rb:30:in `require'
11: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/api_callable.rb:32:in `<top (required)>'
10: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/api_callable.rb:32:in `require'
9: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/errors.rb:32:in `<top (required)>'
8: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/errors.rb:32:in `require'
7: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/grpc.rb:31:in `<top (required)>'
6: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/grpc.rb:31:in `require'
5: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/grpc-1.18.0-x86_64-linux/src/ruby/lib/grpc/google_rpc_status_utils.rb:16:in `<top (required)>'
4: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/grpc-1.18.0-x86_64-linux/src/ruby/lib/grpc/google_rpc_status_utils.rb:16:in `require'
3: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/googleapis-common-protos-types-1.0.2/lib/google/rpc/status_pb.rb:4:in `<top (required)>'
2: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/googleapis-common-protos-types-1.0.2/lib/google/rpc/status_pb.rb:4:in `require'
1: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-x86_64-linux/lib/google/protobuf.rb:48:in `<top (required)>'
/home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-x86_64-linux/lib/google/protobuf.rb:48:in `require': cannot load such file -- google/2.6/protobuf_c (LoadError)
24: from app.rb:1:in `<main>'
23: from app.rb:1:in `require'
22: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore.rb:17:in `<top (required)>'
21: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore.rb:17:in `require'
20: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/client.rb:16:in `<top (required)>'
19: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/client.rb:16:in `require'
18: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1.rb:16:in `<top (required)>'
17: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1.rb:16:in `require'
16: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1/firestore_client.rb:26:in `<top (required)>'
15: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-cloud-firestore-0.24.2/lib/google/cloud/firestore/v1beta1/firestore_client.rb:26:in `require'
14: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax.rb:30:in `<top (required)>'
13: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax.rb:30:in `require'
12: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/api_callable.rb:32:in `<top (required)>'
11: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/api_callable.rb:32:in `require'
10: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/errors.rb:32:in `<top (required)>'
9: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/errors.rb:32:in `require'
8: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/grpc.rb:31:in `<top (required)>'
7: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-gax-1.5.0/lib/google/gax/grpc.rb:31:in `require'
6: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/grpc-1.18.0-x86_64-linux/src/ruby/lib/grpc/google_rpc_status_utils.rb:16:in `<top (required)>'
5: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/grpc-1.18.0-x86_64-linux/src/ruby/lib/grpc/google_rpc_status_utils.rb:16:in `require'
4: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/googleapis-common-protos-types-1.0.2/lib/google/rpc/status_pb.rb:4:in `<top (required)>'
3: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/googleapis-common-protos-types-1.0.2/lib/google/rpc/status_pb.rb:4:in `require'
2: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-x86_64-linux/lib/google/protobuf.rb:47:in `<top (required)>'
1: from /home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-x86_64-linux/lib/google/protobuf.rb:50:in `rescue in <top (required)>'
/home/matt/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/google-protobuf-3.6.1-x86_64-linux/lib/google/protobuf.rb:50:in `require': cannot load such file -- google/protobuf_c (LoadError)
I tried cloning this samples repo and grabbing its Gemfile.lock
, copying it into my test directory, installing its particular version of bundler
(1.17.3), switching to Ruby 2.5.0 with rbenv, running bundle install
and then running my program again with bundle exec ruby app.rb
, and this time it works:
Created Cloud Firestore client with project ID REDACTED .
Added data to the alovelace document in the users collection.
I don't have a ton of Ruby experience, so I don't know exactly what's wrong, but to me the stack trace makes it look like there's an issue with how the latest version of the google-cloud-firestore
gem is wired up to its dependency gems. It might have to do with the "proto_c" in the stack trace.
Thank you for trying this out, @welkie. But, this is blocked on https://github.com/googleapis/google-cloud-ruby/issues/2825. Sorry I forgot to update this bug.
@tbpg Thanks for following up with me. I should have posted back that I found that issue while digging further. I was able to follow its workaround to get it running on 2.6.0 (setting platform to ruby
) but I found those steps complicated and error prone. I'll wait for official 2.6 support. :+1:
Greetings, we're closing this. Looks like the issue got resolved. Please let us know if the issue needs to be reopened.
cc @TheRoyalTnetennba