-
Notifications
You must be signed in to change notification settings - Fork 189
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
Bundler environment not properly reset? #190
Comments
@tknerr it's not the bundler environment so much as the ruby environment. |
Ooops, it might in fact be an upstream Vagrant issue though. So this is my Vagrant:
Just to make sure, even in the bundle context it's the right one:
So plain
@sethvargo so you would expect too that vagrant uses it's own internal bundler version, right? |
@sethvargo thanks for the clarification! So here's my
Anything I could check for that would indicate the ruby environment is not properly set? |
@sethvargo could repro this in a clean environment without any ChefDK or kitchen-vagrant at all:
@sethvargo should I open an issue in Vagrant for this, or is this expected? My understanding was that vagrant should never see the outer bundler version, only the one it ships with. |
Hi @tknerr
|
@sethvargo yes I know, I don't have it installed as a gem :-) Just double-checked:
However, my test-kitchen and kitchen-vagrant versions are managed in a Gemfile, so in the end they shell out to Vagrant from within a bundle context. That's why I was calling it via |
@tknerr that's my point though - they should not be retaining the context from within a bundle. They should be shelling out using the same environment as if you ran
|
@sethvargo ok, got it. Thanks for clarification and your patience! :-) |
I've submitted #191 to attempt to fix this so that we can bump bundler's version in chef-dk. |
I don't think this is test kitchen's problem to solve. Vagrant's loader (when installed as an Omnibus package) should be unsetting any conflicting environment variables set by Bundler. |
@mfischer-zd Vagrant actually does that as of Vagrant 1.7.4. We grab the environment that existed before Vagrant was executed and reset to that (hashicorp/vagrant-installers#57). The problem is that Test Kitchen is "execing" to Vagrant but not resetting it's environment. Vagrant has no way of knowing what the environment was before Test Kitchen was run. Does that make sense? |
@sethvargo I see the save/restore part, but as far as I can tell, only |
@mfischer-zd that is the pre-Ruby Go launcher that just copies the current env (which might include GEM_* and RUBY* envvars, especially if the caller uses a ruby version manager like RVM or chruby. When Vagrant runs, bundler will modify all those fields, but then Vagrant restores the original (VAGRANT_ORIGINAL_ENV) anytime it execs to a subprocess. The problem occurs if Vagrant is executed from within an existing Ruby that isn't properly unsetting those variables when it shells out to Vagrant. Omnibus Chef works fine because it takes the same "restore the entire env before invocation when shelling out" approach. I think TK just needs to mirror that. |
Vagrant should expect that. My contention is that any omnibus-packaged application that arranges for its own runtime environment (and that includes Vagrant) should consider its environment tainted and act accordingly so that it can load its own Gems without the caller getting in its way. It is true that if Vagrant does this, its process descendants won't have access to the bundler/rbenv/etc environment associated with TK. I don't see this as a practical problem, though. What would break? |
The fix for this makes it so we can't have a pre_create_command that uses the bundle driver:
pre_create_command: bundle exec do_something.rb I want to do that, I'd have to have it install the bundle again. This doesn't seem like the right fix to solve the vagrant vs bundler problems. I think it's a vagrant issue because you can clearly make it happen w/o even using test-kitchen or kitchen-vagrant. They (vagrant) should be resetting RUBYLIB. Its launcher is already doing that for RUBYOPT. |
Forking off an issue from the related discussion here:
hashicorp/vagrant#6158
So I have:
gem install bundler -v 1.10.6
Now whenever I
bundle exec kitchen create
I get an error like this:This is weird because Vagrant should never see that it's called from a bundled context, eventually with a bundler version that is not compatible. In fact Vagrant ships with it's own version of bundler (1.10.5 in that case) and should never see the outer bundler.
@sethvargo suggests here that this might have something to do with the bundler environment not being correctly cleaned / restored
The text was updated successfully, but these errors were encountered: