Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

key not found: "UPLOADCARE_SECRET_KEY" (KeyError) #105

Closed
GuillaumeOcculy opened this issue Apr 26, 2022 · 1 comment
Closed

key not found: "UPLOADCARE_SECRET_KEY" (KeyError) #105

GuillaumeOcculy opened this issue Apr 26, 2022 · 1 comment
Labels

Comments

@GuillaumeOcculy
Copy link
Contributor

GuillaumeOcculy commented Apr 26, 2022

I have this error when I try to run rails server

$ rails server
/Users/guillaume/.rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/uploadcare-ruby-3.3.1/lib/uploadcare.rb:36:in `fetch': key not found: "UPLOADCARE_SECRET_KEY" (KeyError)
Did you mean?  "UPLOADCARE_PUBLIC_KEY"

This is not a ENV problem because I wrote my credentials directly on config/initializers/uploadcare.rb and still have the same issue

Uploadcare::Rails.configure do |config|
  # Sets your Uploadcare public key.
  config.public_key = 'mypublickey' # ENV.fetch("UPLOADCARE_PUBLIC_KEY", "mypublickey")
  config.secret_key = 'mysecretkey' # ENV.fetch("UPLOADCARE_SECRET_KEY", "mysecretkey") 
...
# .env
UPLOADCARE_PUBLIC_KEY=mypublickey
UPLOADCARE_SECRET_KEY=mysecretkey

The only way to fix it right now is to run export UPLOADCARE_PUBLIC_KEY=demopublickey but it is not the solution

Environment

  • Library version: uploadcare-rails (2.1.0) uploadcare-ruby (3.3.1) dotenv-rails (2.7.6)
  • Language/framework version: rails (7.0.2.3) ruby (3.0.3)
  • OS version: OS X (12.3.1)
@GuillaumeOcculy
Copy link
Contributor Author

GuillaumeOcculy commented Apr 27, 2022

I figured it out.
If we use dotenv-rails gem, Gemfile should be like this

...
gem "dotenv-rails", require: "dotenv/rails-now", groups: [:development, :test]
gem "uploadcare-rails"

I created a PR #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant