vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Vagrant can't be used with Ruby installed via asdf

Open darwin67 opened this issue 3 years ago • 3 comments

When trying to use vagrant command with a system having Ruby installed via asdf, the embeded ruby with Vagrant will get entangled with the user installed Ruby and fail.

Debug output

https://gist.github.com/darwin67/3311525d2af504751b54ce037c3272ef

Expected behavior

The desired behavior is Vagrant should just use the Ruby version that it comes with from installers and leave the user installed version alone.

Actual behavior

Vagrant embeded ruby calling user installed Ruby. Completely uninstalling Ruby from asdf seems to resolve the issue but that's not a real solution.

Reproduction information

Vagrant version

2.3.0

Host operating system

Arch Linux

Guest operating system

N/A

Steps to reproduce

  1. Install vagrant via sudo pacman -S vagrant
  2. Install Ruby via asdf asdf install ruby 2.7.0 and then set it as global asdf global ruby 2.7.0 (ruby version doesn't really matter, 3.x also have similar issues)
  3. Run vagrant in the command line and the error should show up.

Vagrantfile

N/A

darwin67 avatar Oct 07 '22 20:10 darwin67

FYI, since Ruby 2.3 is end of life and uses an incompatible version of openssl iirc, I can't install 2.3.0 to try to match the embeded version for work around. Just doesn't work.

darwin67 avatar Oct 07 '22 20:10 darwin67

FYI, since Ruby 2.3 is end of life and uses an incompatible version of openssl iirc, I can't install 2.3.0 to try to match the embeded version for work around. Just doesn't work.

2.3.0 is the version of Vagrant, not the Ruby version.

That being said, I have the same issue, same error. In my case, Ruby is managed by rbenv.

geewiz avatar Oct 12 '22 06:10 geewiz

Would you please provide a gist of the debug output from running the command (all output when the --debug flag is included).

Thanks!

chrisroberts avatar Oct 14 '22 22:10 chrisroberts

In my case, Vagrant is called from test-kitchen (more precisely, its kitchen-vagrant plugin), and I don't think I can make it use the debug flag. Here's the output as is:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider virtualbox ----
STDOUT: 
STDERR: Ignoring bcrypt_pbkdf-1.1.0 because its extensions are not built. Try: gem pristine bcrypt_pbkdf --version 1.1.0
Ignoring date-3.2.2 because its extensions are not built. Try: gem pristine date --version 3.2.2
Ignoring ed25519-1.3.0 because its extensions are not built. Try: gem pristine ed25519 --version 1.3.0
Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
Ignoring wdm-0.1.1 because its extensions are not built. Try: gem pristine wdm --version 0.1.1
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:13: warning: already initialized constant Ed25519::KEY_SIZE
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:13: warning: previous definition of KEY_SIZE was here
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:16: warning: already initialized constant Ed25519::SIGNATURE_SIZE
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:16: warning: previous definition of SIGNATURE_SIZE was here
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:19: warning: already initialized constant Ed25519::VerifyError
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:19: warning: previous definition of VerifyError was here
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:22: warning: already initialized constant Ed25519::SelfTestFailure
/opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:22: warning: previous definition of SelfTestFailure was here
/home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- ed25519_ref10 (LoadError)
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:35:in `<module:Ed25519>'
        from /opt/vagrant/embedded/gems/2.3.2/gems/ed25519-1.3.0/lib/ed25519.rb:9:in `<top (required)>'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /opt/vagrant/embedded/gems/2.3.2/gems/net-ssh-6.1.0/lib/net/ssh/authentication/ed25519.rb:4:in `<top (required)>'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /opt/vagrant/embedded/gems/2.3.2/gems/vagrant-2.3.2/lib/vagrant/patches/net-ssh.rb:162:in `<top (required)>'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /opt/vagrant/embedded/gems/2.3.2/gems/vagrant-2.3.2/lib/vagrant.rb:19:in `<top (required)>'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:158:in `require'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:147:in `require'
        from /opt/vagrant/embedded/gems/2.3.2/gems/vagrant-2.3.2/bin/vagrant:111:in `<main>'
/home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require': cannot load such file -- vagrant (LoadError)
        from /home/geewiz/.rbenv/versions/2.7.5/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
        from /opt/vagrant/embedded/gems/2.3.2/gems/vagrant-2.3.2/bin/vagrant:111:in `<main>'
---- End output of vagrant up --no-provision --provider virtualbox ----
Ran vagrant up --no-provision --provider virtualbox returned 1] on fpm-ubuntu-2004
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

From this output, it's clear that Vagrant's gems in /opt/vagrant/embedded/gems get mixed up with my rbenv gems in /home/geewiz/.rbenv.

geewiz avatar Nov 09 '22 14:11 geewiz

I think my issues are not caused by a bug in Vagrant. I just cloned and installed the repo, and it works on my Manjaro Linux. Based on this, it's more likely the most recent Arch Linux build that's broken.

geewiz avatar Nov 10 '22 14:11 geewiz