I am using Ruby on Rails with Google App Engine, i.e. this tutorial: https://cloud.google.com/ruby/getting-started/hello-world. I am using Google Datastore instead of a conventional database. For production, I am easily able to connect to my project's datastore, however development mode using the Google Datastore Emulator proves an issue. I was able to install the Datastore Emulator and get it up and running using the provided google tutorial (https://cloud.google.com/datastore/docs/tools/datastore-emulator).
I run the datastore emulator, then run gcloud beta emulators datastore env-init and make sure those environment variables are in my .bashrc file (and source my .bashrc file).
My environment variables look something like this:
export DATASTORE_DATASET=my-app
export DATASTORE_HOST=http://localhost:8473
export DATASTORE_EMULATOR_HOST=localhost:8473
export DATASTORE_PROJECT_ID=my-app
Then I try to do the following from within Rails:
require 'gcloud'
gcloud = Gcloud.new('my-app')
dataset = gcloud.datastore
This results in the following error from the 'gcloud' gem:
RuntimeError: Could not load the default credentials. Browse to
https://developers.google.com/accounts/docs/application-default-credentials
for more information
from /home/sam/.rvm/gems/ruby-2.2.3/gems/googleauth-0.5.1/lib/googleauth.rb:119:in `get_application_default'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/gcloud-0.7.2/lib/gcloud/credentials.rb:83:in `default'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/gcloud-0.7.2/lib/gcloud/datastore.rb:62:in `datastore'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/gcloud-0.7.2/lib/gcloud.rb:106:in `datastore'
from (irb):3
from /home/sam/.rvm/gems/ruby-2.2.3/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/sam/.rvm/gems/ruby-2.2.3/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:18:in `require'
from bin/rails:18:in `<main>'
I was under the impression I did not need a keyfile if using the datastore emulator. If I do need a keyfile, how do I create one that will let me connect to the local datastore emulator? The datastore emulator documentation doesn't mention the need for this at all, and seems to suggest that merely having the environment variables in place should be enough for local clients to connect automatically.
Please advise!