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

Issues with Bundler.setup mangling $LOAD_PATH #5172

p8952 opened this issue Jan 11, 2015 · 2 comments

Issues with Bundler.setup mangling $LOAD_PATH #5172

p8952 opened this issue Jan 11, 2015 · 2 comments


Copy link

p8952 commented Jan 11, 2015

I'm using Vagrant 1.6.5 in a non-standard and non-supported environment. I'm also unsure if this is an issue with Vagrant itself or Bundler.

I am using system Ruby and have installed Vagrant 1.6.5 from the 1.6.5 git tag. I have documented the specific steps I take to install Vagrant here.

When running Vagrant from a directory containing a Gemfile, or a sub-directory where the parent has a Gemfile I receive the following error:

`require': cannot load such file -- log4r (LoadError)

The error is raised from here and seems to be caused by the call to Bundler.setup here. Prior to this call my $LOAD_PATH contains the following:


However after Bundler.setup us called my $LOAD_PATH becomes:


Which is why Vagrant can't require log4r. When running in a directory without a Gemfile the my $LOAD_PATH remains unmodified.

I assume this is because Bundler is locking me into an environment with only the contents of the Gemfile available? I also assume for whatever reason this behaviour is not present in the versions of Vagrant which ship with their dependencies pre-packaged?

I understand my environment is non-standard and non-supported so feel free to close this if it's just a case of "Don't do that", however any help or advice is much appreciated.

Copy link

p8952 commented Jan 12, 2015

For now I'm wrapping this block of code with the following to restore the $LOAD_PATH. This seems to resolve the issue in my case.

load_path = []
$LOAD_PATH.each { |path| load_path << path }
load_path.each { |path| $LOAD_PATH.push(path) unless $LOAD_PATH.include?(path) }

Copy link

This is definitely a "don't do that". However, if you can find a way to work around it please let us know. The issue is that the existence of a Gemfile in a non-standard environment tells Vagrant to think it is in "dev mode" so it uses the bundle, assuming that all of its dependencies are in there.

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

No branches or pull requests

2 participants