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

Embedded bundler clashing with my bundler #3193

Closed
danp opened this issue Mar 13, 2014 · 19 comments
Closed

Embedded bundler clashing with my bundler #3193

danp opened this issue Mar 13, 2014 · 19 comments

Comments

@danp
Copy link

danp commented Mar 13, 2014

I think vagrant's embedded bundler is clashing with my bundler when vagrant is run within bundle exec. I am using vagrant 1.5.0, this reproduces it for me:

$ mkdir vagrant-bundler-clash
$ cd vagrant-bundler-clash
$ cat > Gemfile << EOF
source "https://rubygems.org"
gem "sinatra"
EOF
$ bundle install
$ bundle exec vagrant
/Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/bundler.rb:31:in `initialize': undefined method `new' for Bundler::UI:Module (NoMethodError)
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/bundler.rb:17:in `new'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.0/lib/vagrant/bundler.rb:17:in `instance'
    from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.5.0/lib/vagrant/pre-rubygems.rb:22:in `<main>'

I think I was able to use 1.4 within bundle exec but I'm not sure.

@mitchellh
Copy link
Contributor

Hah you're right.

@mitchellh
Copy link
Contributor

Working on a fix now.

@danp
Copy link
Author

danp commented Mar 13, 2014

Maybe more a vagrant-installers issue. Adding this:

unset BUNDLE_BIN_PATH
unset BUNDLE_GEMFILE
unset RUBYLIB
unset RUBYOPT

to the vagrant template fixes it locally for me. This emulates (and then some) what Bundler.with_clean_env does.

@mitchellh
Copy link
Contributor

I fixed it in core, try to bundle upate and see if that works

@danp
Copy link
Author

danp commented Mar 13, 2014

Thanks! I'm using vagrant on OS X as installed with the installer, where should I bundle update?

@mitchellh
Copy link
Contributor

Wherever it is clashing

@danp
Copy link
Author

danp commented Mar 13, 2014

The issue is that the vagrant embedded ruby is being run with $RUBYOPT and $RUBYLIB (among other things) as set by my bundle exec. I would strongly recommend cleaning the env a bit more in /usr/bin/vagrant as I suggested above or somewhere before you run the vagrant-embedded ruby.

To get the change you did make I'm pretty sure the only thing I can do locally is update the embedded vagrant gem under /Applications/Vagrant. I'm not using vagrant as a gem and it's not anything in my bundle that's causing this issue.

@mitchellh
Copy link
Contributor

When you run bundle exec vagrant it shouldn't be hitting the normally installed Vagrant.

@danp
Copy link
Author

danp commented Mar 13, 2014

It is, because I don't have vagrant in my bundle. I'm treating vagrant as installed with the OS X installer as a system app/service. Is that not the right approach?

I am using things like test-kitchen which I do put in my bundle and therefore want to run under bundle exec. But since that in turn runs vagrant it's running the stuff in /Applications/Vagrant with $RUBYOPT and $RUBYLIB.

$ bundle exec bash -c 'which vagrant'
/usr/bin/vagrant

@mitchellh
Copy link
Contributor

Ah I see. Vagrant will not work in this way. It will not be able to read any of your Gemfile dependencies.

@danp
Copy link
Author

danp commented Mar 13, 2014

I don't want it to.

@mitchellh
Copy link
Contributor

Good! Then the commit I made should fix it.

@danp
Copy link
Author

danp commented Mar 13, 2014

I don't think we are on the same page. :( I will locally add the unsets I listed above back to /usr/bin/vagrant. I will try to come back around later and explain better. Sorry for the confusion.

@kforsthoevel
Copy link

I'm using vagrant 1.5.1 on Mac OS X and having the same problem as above with bundler 1.6.0:

$ bundle -v
Bundler version 1.6.0
$ bundle exec vagrant status
/Applications/Vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:31:in `initialize': undefined method `new' for Bundler::UI:Module (NoMethodError)
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:17:in `new'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:17:in `instance'
    from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.5.1/lib/vagrant/pre-rubygems.rb:22:in `<main>'

Everything is fine with bundler 1.5.3:

$ bundle -v
Bundler version 1.5.3
$ bundle exec vagrant status
Current machine states:

default                   not created (virtualbox)

The environment has not yet been created. Run `vagrant up` to
create the environment. If a machine is not created, only the
default provider will be shown. So if a provider is not listed,
then the machine is not created for that environment.

Is there anything I'm doing wrong? Thanks.

@hyfather
Copy link

hyfather commented Apr 1, 2014

Seeing the same thing.

/opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:31:in `initialize': undefined method `new' for Bundler::UI:Module (NoMethodError)
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:17:in `new'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:17:in `instance'
    from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.5.1/lib/vagrant/pre-rubygems.rb:22:in `<main>'

root@exec05:~# vagrant --version
Vagrant 1.5.1
root@exec05:~# find /opt/vagrant -iname bundler
/opt/vagrant/embedded/gems/bin/bundler
/opt/vagrant/embedded/gems/gems/bundler-1.5.3/lib/bundler
/opt/vagrant/embedded/gems/gems/bundler-1.5.3/bin/bundler
/opt/vagrant/embedded/gems/gems/bundler-1.5.3/spec/bundler

Bundler::UI (bundler/lib/bundler/ui.rb) ceased to be a class in bundler-1.5.2. It is a module in bundler-1.5.3. Should Vagrant-1.5.1 use bundler-1.5.2 instead? Any way to override this without a newer Vagrant?

EDIT: Bundler::UI is a module in 1.6.0 not in 1.5.3.

@danp
Copy link
Author

danp commented Apr 1, 2014

I'm guessing when 1.5.2 is released and a new installer is built with hashicorp/vagrant-installers#33 this will be fixed. Until then, you can edit /usr/bin/vagrant and add RUBYLIB to the end of the unset RUBYOPT line.

@rudisimo
Copy link

rudisimo commented Apr 2, 2014

@dpiddy By the way, if you downgrade bundler to a version less than 1.6.x the problem goes away. One of our developers was having this same problem with a Rakefile, which would call vagrant through a system command; but it wasn't happening to anyone else.

Our environment were setup almost identical, except for bundler. He was using 1.6.1 and I had 1.5.3. As soon as he downgraded the gem, the problem went away.

This was the warning:

/Applications/Vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:31:in `initialize': undefined method `new' for Bundler::UI:Module (NoMethodError)
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:17:in `new'
    from /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.1/lib/vagrant/bundler.rb:17:in `instance'
    from /Applications/Vagrant/bin/../embedded/gems/gems/vagrant-1.5.1/lib/vagrant/pre-rubygems.rb:22:in `<main>'

Anyways, thanks for the explanation. It definitely saved the day for us. 👍

@paulRbr
Copy link

paulRbr commented Apr 29, 2014

updating vagrant to 1.5.2 solved it for me, thanks @dpiddy and @mitchellh 👍

@maoueh
Copy link

maoueh commented Apr 30, 2014

It seems that for bundler 1.6, Bundler::UI is now a module where it was a class before. Hence, it's not possible to instantiate anymore.

The class lib/vagrant/bundler is not ready yet for bundler 1.6. See issue #3451 for more info.

Until then, this error can appear strangly when using test-kicthen with kicthen-vagrant as it will report the following error:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Detected an old version of Vagrant (). Please upgrade to version 1.1.0 or higher from http://downloads.vagrantup.com/.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

While the error is simply that the version check failed in which case it prints this error.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants