Open gbonk opened 7 years ago
I put some 'puts' in the area that the exception is thrown. Don't know if it helps but it appears to be that berkshelf is not on the 'classpath' even though it is when I list it, and I had installed it with a 'gem install'
Gem::Specification.each do | spec|
puts spec
end
AND
puts Gem.path
Results in: C:/HashiCorp/Vagrant/embedded/gems
$ which ruby /c/opscode/chefdk/embedded/bin/ruby
$ which gem /c/opscode/chefdk/embedded/bin/gem
$ gem list --local | grep berk berkshelf (5.6.4, 5.6.3, 5.6.0, 5.5.0) berkshelf-api-client (3.0.0) vagrant-berkshelf (5.1.1)
Further investigation shows that, In Ruby, if the GEM_HOME environment variable is set then that OVERRIDES the "Gem.default_dir" path for Gems.
Putting a "puts ENV" at the beginning of C:\opscode\chefdk\embedded\bin\berks.rb shows that when U run a vagrant up "GEM_PATH": "C:\HashiCorp\Vagrant\embedded\gems" BUT when I run ruby /c/opscode/chefdk/embedded/bin/berks --version --format json
from my git bash, the command runs fine and in my Shell env there is no GEM_PATH set.
I'm not sure then if this is a Vagrant issue or a Plugin issue. Tho I am going to check in with Vagrant as well
In Vagrant-Berkshelf/helpers.rb there is a call to "Vagrant::Util::Env.with_clean_env do".
I'm not sure if there is something here in the beginning of the plugin that would work better ?
Yes, if I update "~.vagrant.d\gems\2.2.5\gems\vagrant-berkshelf-5.1.1\lib\vagrant-berkshelf\helpers.rb" and add the following at line 62
ENV.delete("GEM_HOME" )
ENV.delete("GEM_PATH" )
Everything works fine
Thanks so much @gbonk, I've been stuck on this issue for months now. Thought it was a dark incompatibility between ChefDK, Vagrant and Berkshelf on particular conditions but it's far more simpler than that. I can finally use Vagrant again on Archlinux.
Based on what @gbonk suggested , there is a less invasive hack which might work for some people.
Just add these lines at the top of your Vagrantfile :
ENV["GEM_PATH"] = nil
ENV["GEM_HOME"] = nil
It works for me while using rbenv to manage my ruby versions.
I'm trying to perform a fresh install with the latest of everything and using the Chocolatley provisioner on a windows 7 machine.
I have....
Here is my Vagrant File..
and my Berksfile
When I vagrant up, I receive the following warning and error...