ruby-on-railsherokuenvironment-variablesfigaro-ruby

Change Figaro gem environment variables heroku


I'm developing an app for a client.

I wanted to be able to get it up and running, so I used my own API keys for Facebook and Google (also for Amazon AWS) so that they could at least see how it looked before they created their accounts on those same systems so I could use their API keys.

Now that they have created their accounts, I'm wanting to change my API keys in my application.yaml file, but when I go to run figaro heroku:set -e production, I get the error:

/Users/celly/.rubies/ruby-2.2.2/lib/ruby/2.2.0/psych.rb:370:in `parse': (<unknown>): did not find expected key while parsing a block mapping at line 14 column 1 (Psych::SyntaxError)
    from /Users/celly/.rubies/ruby-2.2.2/lib/ruby/2.2.0/psych.rb:370:in `parse_stream'
    from /Users/celly/.rubies/ruby-2.2.2/lib/ruby/2.2.0/psych.rb:318:in `parse'
    from /Users/celly/.rubies/ruby-2.2.2/lib/ruby/2.2.0/psych.rb:245:in `load'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/application.rb:60:in `parse'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/application.rb:56:in `block in raw_configuration'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/application.rb:56:in `yield'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/application.rb:56:in `raw_configuration'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/application.rb:64:in `global_configuration'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/application.rb:32:in `configuration'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/cli/task.rb:19:in `configuration'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/cli/heroku_set.rb:7:in `run'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/cli/task.rb:9:in `run'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/lib/figaro/cli.rb:38:in `block in <class:CLI>'
    from /Users/celly/.gem/ruby/2.2.2/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/celly/.gem/ruby/2.2.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/celly/.gem/ruby/2.2.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/celly/.gem/ruby/2.2.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/celly/.gem/ruby/2.2.2/gems/figaro-1.1.1/bin/figaro:5:in `<top (required)>'
    from /Users/celly/.gem/ruby/2.2.2/bin/figaro:23:in `load'
    from /Users/celly/.gem/ruby/2.2.2/bin/figaro:23:in `<main>'

I suspect that it has to do with the fact that they keys no longer match the keys that were there previously.

Unfortunately, I see nothing in the documentation for Figaro that talk about changing the keys. Everything I've seen in my searching has to deal with proper indentations, but I know the indentation is proper because it was working just fine before changing the keys.

Any help would be greatly appreciated.

EDIT: ADDING CODE FROM application.yaml

# Add configuration values here, as shown below.
#
# pusher_app_id: "2954"
# pusher_key: 7381a978f7dd7f9a1117
# pusher_secret: abdc3b896a0ffb85d373
# stripe_api_key: sk_test_2J0l093xOyW72XUYJHE4Dv2r
# stripe_publishable_key: pk_test_ro9jV5SNwGb1yYlQfzG17LHK
#
# production:
#   stripe_api_key: sk_live_EeHnL644i6zo4Iyq4v1KdV9H
#   stripe_publishable_key: pk_live_9lcthxpSIHbGwmdO941O1XVU

# For Facebook authentication
FACEBOOK_CONSUMER_KEY: "consumer key"
FACEBOOK_CONSUMER_SECRET: "secret key"

# For Google authentication
GOOGLE_APP_ID: "app id"
GOOGLE_APP_SECRET: "secret key"

# For image upload to Amazon Web Services
AWS_BUCKET: "myafrolink"
AWS_ACCESS_KEY_ID: "access id"
AWS_SECRET_ACCESS_KEY: "secret key"

Again, I want to reiterate that everything was working absolutely fine before i changed the values of the keys, even without specifying development or production blocks.


Solution

  • Tested something with the hopes that it would work, and it did.

    Apparently, I had to remove the current environment variables from heroku so that figaro could reset them to the new values.

    heroku config:unset VARIABLE_NAME was able to successfully do this. Once that was complete, I re-ran figaro heroku:set -e production and was able to proceed with zero errors.

    My guess is that figaro can only set the variables. When it comes across a variable that has changed, it doesn't know what to do, so unsetting the variable through heroku allows figaro to reset the variable to whatever values you choose.