I'm having trouble using an environment variable in my Gemfile.
I'm trying to load a gem from a private Github repository with an API key:
auth = ENV['SECRET_GIT']
gem 'foobar', git: "https://#{auth}:[email protected]/Foo/Bar.git"
But if I puts
my ENV['SECRET_GIT']
variable, there's nothing in it.
I though you could do it this way because of these (especially the first one):
- https://devcenter.heroku.com/articles/bundler-configuration#gem-source-username-and-password
- https://stackoverflow.com/a/7338154/5353193
- Deploying to Heroku with environment variables in Gemfile
Bundler version 1.14.6
ruby 2.4.0p0
Thank you for you help
EDIT
I'm trying to do this in my local environment, I guess there would be no problem doing this on heroku.
Well yes you can set it from console
heroku config:set SECRET_GIT=your-api-key
Or, you can set the environment variables from heroku dashbord
heroku > your-app > settings > Config variables
And add a new entry
SECRET_GIT = your-api-key
And now you can use it directly in Gemfile
gem 'foobar', git: "https://#{ENV['SECRET_GIT']}:[email protected]/Foo/Bar.git"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With