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

VAULT_ADDR is not respected if set with ENV['VAULT_ADDR'] = 'foo' #208

Open
rileytg opened this issue Sep 17, 2019 · 1 comment
Open

VAULT_ADDR is not respected if set with ENV['VAULT_ADDR'] = 'foo' #208

rileytg opened this issue Sep 17, 2019 · 1 comment

Comments

@rileytg
Copy link

rileytg commented Sep 17, 2019

$ unset VAULT_ADDR
$ cat test-vault.rb 
require 'vault'
ENV['VAULT_ADDR'] = 'foo'
puts Vault.address 

$ ruby test-vault.rb 
https://127.0.0.1:8200

Expected result is foo

I stumbled upon this because I use the dotenv-rails gem for loading project specific env variables. I suspect it's because the ENV vars are read when the gem is required.

is this an intentional design? Is there anything i can do other than run this in my setup code:

Vault.address = ENV['VAULT_ADDR']
Vault.token = ENV['VAULT_TOKEN']
@lukasz-wojcik
Copy link

lukasz-wojcik commented Dec 20, 2019

I believe an answer is in the dotenv-rails README: https://github.com/bkeepers/dotenv#note-on-load-order

Do it like this in the Gemfile:

gem 'dotenv-rails', require: 'dotenv/rails-now', group: [:development, :test]
gem 'vault', '~> X.X'

all should work fine

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

No branches or pull requests

2 participants