vagrant 1.9.x
Mac OS X 10.10
The env[:gems_path] variable up to Vagrant 1.8.x pointed to ~/.vagrant.d/gems (set in https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/environment.rb#L124).
Since version 1.9.0 however, the actual path where plugins are installed contains the Ruby version (2.2.5): ~/.vagrant.d/gems/2.2.5 while the env[:gems_path] variable is not updated accordingly.
The code that configures this path can be found here:
https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/bundler.rb#L30
This breaks plugins that rely on the env[:gems_path] variable to find executables installed with plugins,
for example vagrant-librarian-puppet: https://github.com/voxpupuli/vagrant-librarian-puppet/blob/master/lib/vagrant-librarian-puppet/action/librarian_puppet.rb#L23
There's two ways to go about this I guess:
1) Adding the RUBY_VERSION to the env[:gems_path] variable: this would however invalidate
all plugins when a new Vagrant (with updated Ruby) is installed.
2) Removing the RUBY_VERSION from the plugin install path altogether, which would avoid the problem in 1). But maybe there was a specific reason to add it I am unaware of.
I'd be happy to provide a pull request either way, if someone more familiar with the code could steer me in the right direction.
I use Vagrant to test Puppet modules locally. I have macOS 10.12.1 and recently saw VirtualBox 5.1 was out. I hadn't updated that in a while, so I did it, and also went from Vagrant 1.8.1 to 1.9.1. I have the following plugins:
$ vagrant plugin list
puppet (4.8.2)
vagrant-cachier (1.2.1)
vagrant-host-shell (0.0.4)
vagrant-puppet-install (4.1.0)
vagrant-r10k (0.4.1)
vagrant-share (1.1.6, system)
Could this issue be why I've been getting the error below whenever I run vagrant up or provision? It looks furiously like it's a Vagrant Ruby env issue and I couldn't resolve it by doing a clean install. And it works fine with Vagrant 1.8.6. I'm having a separate issue with 1.8.7 that's preventing me from testing this with the latest 1.8.x.
$ vagrant provision
==> default: vagrant-r10k: Puppet provisioner module_path is nil, assuming puppet4 environment mode
==> default: vagrant-r10k: Puppet provisioner module_path is nil, assuming puppet4 environment mode
==> default: vagrant-r10k: Puppet provisioner module_path is nil, assuming puppet4 environment mode
==> default: vagrant-r10k: Beginning r10k deploy of puppet modules into /Users/fdelpierre/Code/jenkinsdocker/vagrant/environments/dev/modules using /Users/fdelpierre/Code/jenkinsdocker/vagrant/Puppetfile
INFO -> Loading modules from Puppetfile into queue
INFO -> Deploying resolv_conf into /Users/fdelpierre/Code/jenkinsdocker/vagrant/environments/dev/modules
ERROR -> Task #<R10K::Task::Module::Sync:0x00000102bc7db8> failed while running: Command exited with non-zero exit code:
Command: puppet module --modulepath /Users/fdelpierre/Code/jenkinsdocker/vagrant/environments/dev/modules --color false install --force jonnyx/resolv_conf
Stderr:
/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'puppet' (>= 0.a) among 45 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/opt/vagrant/embedded/gems', execute `gem env` for more information
from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/dependency.rb:324:in `to_spec'
from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /Users/fdelpierre/.rvm/gems/ruby-2.3.1/bin/puppet:22:in `<main>'
from /Users/fdelpierre/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/fdelpierre/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
Exit code: 1
INFO -> Purging stale modules from /Users/fdelpierre/Code/jenkinsdocker/vagrant/environments/dev/modules
INFO -> Removing unmanaged path /Users/fdelpierre/Code/jenkinsdocker/vagrant/environments/dev/modules/jenkinsdocker
Vagrant only chokes if I have anything in the Puppetfile I use to tell r10k what modules to grab. If the Puppetfile is empty, everything runs totally fine. r10k needs the puppet gem to interact with the Puppet Forge, so it looks for -- and cannot find -- the gem in the path it's looking at, so it exits. The gem is indeed absent from the path indicated above (/opt/vagrant/embedded/gems), but it's installed in ~/.vagrant.d/gems/2.2.5/gems, and like I said this works fine with Vagrant 1.8.6.
Also, if I have anything in my Puppetfile but the module is already present in Puppet's modulepath, Vagrant proceeds normally, but that's because r10k sees it has nothing to do.
So it sounds like this issue is related to my problem, but if I'm mistaken, please let me know, and apologies for cluttering this discussion.
Hey @fabiendelpierre, that is indeed the exact symptom I'm seeing. Librarian-puppet is very similar to r10k, and installing the vagrant-librarian-puppet pulls in the puppet gem. Because of the mismatched env[:gems_path], running the plugin to install puppet modules produces the following error:
$ vagrant provision
==> udb3: Installing Puppet modules in "puppet" with Librarian-Puppet...
Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc).
puppet --version returned pid 35485 exit 1
/opt/rubies/1.9.3-p545/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find puppet (>= 0) amongst [builder-3.2.2, childprocess-0.5.9, domain_name-0.5.20161129, erubis-2.7.0, ffi-1.9.14, gssapi-1.2.0, gyoku-1.3.1, hashicorp-checkpoint-0.1.4, http-cookie-1.0.3, httpclient-2.8.2.4, i18n-0.7.0, listen-3.1.5, little-plugger-1.1.4, log4r-1.1.10, logging-2.1.0, mime-types-3.1, mime-types-data-3.2016.0521, mini_portile2-2.0.0, multi_json-1.12.1, net-scp-1.1.2, net-sftp-2.1.2, net-ssh-3.0.2, netrc-0.11.0, nokogiri-1.6.7.1, nori-2.6.0, rb-fsevent-0.9.8, rb-inotify-0.9.7, rb-kqueue-0.2.4, rest-client-2.0.0, ruby_dep-1.3.1, rubyntlm-0.6.1, rubyzip-1.2.0, unf-0.1.4, unf_ext-0.0.7.2, vagrant-1.9.1, vagrant-share-1.1.6, wdm-0.1.1, winrm-1.8.1, winrm-fs-0.3.2] (Gem::LoadError)
from /opt/rubies/1.9.3-p545/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /opt/rubies/1.9.3-p545/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /opt/boxen/rbenv/versions/1.9.3-p545/bin/puppet:22:in `<main>'
Great! Or not really great. I used to use Librarian but switched to r10k, it's much faster in my opinion, but I'm quite familiar with it 😄
Anyway. Hopefully this gets fixed.
This issue seems not fixed. On vagrant 1.9.5 i receive following error:
Installing Puppet modules in "puppet" with Librarian-Puppet...
Unable to load puppet. Please install it using native packages for your platform (eg .deb, .rpm, .dmg, etc).
puppet --version returned pid 2783 exit 1
/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/dependency.rb:315:into_specs': Could not find 'puppet' (>= 0) among 44 total gem(s) (Gem::LoadError) Checked in 'GEM_PATH=/opt/vagrant/embedded/gems', executegem envfor more information from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/dependency.rb:324:into_spec'
from /opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:ingem' from /Users/nils/.vagrant.d/gems/2.2.5/bin/puppet:22:in'
Switching back to 1.8.7 fixes the issue.
Agreed, this is not fixed. I'm having problems with vagrant-r10k not loading Puppet. The root problem is that the Ruby gem loader doesn't load from installed vagrant plugins. Below is the output of gem env as run from inside Vagrant.
Vagrant 1.9.5:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5.1
- RUBY VERSION: 2.2.5 (2016-04-26 patchlevel 319) [x86_64-linux]
- INSTALLATION DIRECTORY: /opt/vagrant/embedded/gems
- RUBY EXECUTABLE: /opt/vagrant/embedded/bin/ruby
- EXECUTABLE DIRECTORY: /opt/vagrant/embedded/gems/bin
- SPEC CACHE DIRECTORY: /home/tjp502/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /vagrant-substrate/staging/embedded/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /opt/vagrant/embedded/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc --no-user-install"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /opt/vagrant/embedded/bin
- /home/tjp502/.rvm/gems/ruby-2.1.10/bin
- /home/tjp502/.rvm/gems/ruby-2.1.10@global/bin
- /home/tjp502/.rvm/rubies/ruby-2.1.10/bin
- /home/tjp502/.rvm/bin
- /home/tjp502/bin
- /home/tjp502/.local/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin
Vagrant 1.8.7:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5.1
- RUBY VERSION: 2.2.5 (2016-04-26 patchlevel 319) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/tjp502/.vagrant.d/gems/ruby/2.2.0
- RUBY EXECUTABLE: /opt/vagrant/embedded/bin/ruby
- EXECUTABLE DIRECTORY: /home/tjp502/.vagrant.d/gems/ruby/2.2.0/bin
- SPEC CACHE DIRECTORY: /home/tjp502/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /vagrant-substrate/staging/embedded/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/tjp502/.vagrant.d/gems/ruby/2.2.0
- /opt/vagrant/embedded/gems
- /home/tjp502/.vagrant.d/gems
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc --no-user-install"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/tjp502/.vagrant.d/gems/ruby/2.2.0/bin
- /opt/vagrant/embedded/bin
- /home/tjp502/.rvm/gems/ruby-2.1.10/bin
- /home/tjp502/.rvm/gems/ruby-2.1.10@global/bin
- /home/tjp502/.rvm/rubies/ruby-2.1.10/bin
- /home/tjp502/.rvm/bin
- /home/tjp502/bin
- /home/tjp502/.local/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /snap/bin
Notice the Gem paths. I believe this broke with 1fb4553, but I can't see how to fix it, since it changed plugin management so fundamentally.
hi @fabiendelpierre ^_^
the path is definitely broken and manifests itself with the copypaste you left above.
the workaround is:
bash# gem install -i /opt/vagrant/embedded/gems puppet (and whatever other requirements are missing, but this worked for me). Notice that this directory is probably owned by root so the commands should be run as such.
However, it's just a workaround.
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
hi @fabiendelpierre ^_^
the path is definitely broken and manifests itself with the copypaste you left above.
the workaround is:
bash# gem install -i /opt/vagrant/embedded/gems puppet(and whatever other requirements are missing, but this worked for me). Notice that this directory is probably owned byrootso the commands should be run as such.However, it's just a workaround.