I can't use vagrant on my laptop

Hi,

I wonder why Nixos doesn’t handle Vagrant correctly ?

The vagrant package launch a build that doesn’t go well on my machine as Vagrant is not usable at the end. Hence, what is wrong ? Is there a technical issue or is it just that this is not considered important ?

Btw even the wiki page about Vagrant is quite unclear about this.

https://nixos.wiki/wiki/Vagrant

I’m currently on a journey to find a way to quickly setup VMs in CLI like with containers but Nixos seems to get in my way.

I’ve seen people talking about it, here are some relevant discussions.

1 Like

Would you post the steps that you are taking to set things up and the error messages where they fail? Thanks!

Hi,

Thanks for replying.

Sorry, I should’ve done it before.

Here is the error I get after entering nix-shell -p vagrant and invoking vagrant.

There seems to be a problem with the ruby version but I do not know a lot about build and dependencies (particularly in NixOS).

First of all, I don’t even understand why vagrant is built, this is the first time that I encounter a build when using nix-shell -p. I was expecting to see nix download a binary.

<internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require': incompatible library version - /home/allan/.local/share/gem/ruby/3.1.0/gems/strscan-3.1.0/lib/strscan.so (LoadError)
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/aamrlb03qjx8xwv3nwbsc32xv62g7fwz-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/net-ssh-7.2.1/lib/net/ssh/known_hosts.rb:1:in `<top (required)>'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/aamrlb03qjx8xwv3nwbsc32xv62g7fwz-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/net-ssh-7.2.1/lib/net/ssh/transport/algorithms.rb:2:in `<top (required)>'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/aamrlb03qjx8xwv3nwbsc32xv62g7fwz-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/net-ssh-7.2.1/lib/net/ssh/transport/session.rb:6:in `<top (required)>'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/aamrlb03qjx8xwv3nwbsc32xv62g7fwz-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/net-ssh-7.2.1/lib/net/ssh.rb:12:in `<top (required)>'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/lqa1z4afxn7d2d0ls66im6l437dnpsqf-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/vagrant-2.4.1/lib/vagrant/patches/net-ssh.rb:4:in `<top (required)>'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/lqa1z4afxn7d2d0ls66im6l437dnpsqf-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/vagrant-2.4.1/lib/vagrant.rb:7:in `<top (required)>'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from <internal:/nix/store/vm2yjlip09dylmrr9rpjqfgz2gi1kky8-ruby-3.1.6/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:136:in `require'
	from /nix/store/lqa1z4afxn7d2d0ls66im6l437dnpsqf-vagrant-2.4.1/lib/ruby/gems/3.1.0/gems/vagrant-2.4.1/bin/vagrant:88:in `<top (required)>'
	from /nix/store/lqa1z4afxn7d2d0ls66im6l437dnpsqf-vagrant-2.4.1/bin/.vagrant-wrapped:18:in `load'
	from /nix/store/lqa1z4afxn7d2d0ls66im6l437dnpsqf-vagrant-2.4.1/bin/.vagrant-wrapped:18:in `<main>'

There is also a lot of error during the build.
But the output is really long, I can still paste the relevant parts, if necessary.

Those error messages look a bit peculiar. Couple of questions:

  • Do other nix-shell -p commands work?
  • What system are you trying to get Vagrant working on?
  • How did you set up Nix?
  • Did you set up a custom nix.conf file?
  • What channel are you on?
    (Not sure this question is relevant anymore though; stopped checking progress on channels / flakes / etc. a while back.)

Before getting your hopes up, please know that I may be the least qualified here to try to figure this one out, but answering those questions will help others get to conclusions and thus help them to give you some tips.

With that said, it looks to me that nix-shell -p vagrant is trying to build the package locally. Although not sure why it would be failing even then…

Thanks again for the answer.

Yes, they all do. This is a first

NixOS 24.05

No

24.05

Ok, nevertheless, I can still benefit from your experience with vagrant. Hence, how did you install vagrant, and was there a local build for you too ?

how did you install vagrant, and was there a local build for you too ?

I did everything the way it’s documented in my post with nix-shell -p vagrant on a newly installed NixOS, so the config wasn’t pretty vanilla too (aside from the changes mentioned in the post).

Speaking of which, do you have your configuration.nix posted somewhere? It may give some clues to folks.

On the other hand:

  • What if you tried a different channel, such as 23.11?
  • Do you get any issue when updating the system?

Other than these, I’m out of ideas for now, sorry.

ok, thanks I’try what you’re suggesting. And what about the local build, did nix-shell -p vagrant built vagrant for you too ?

If you mean that if it was built from source too when I did, then the answer is no; it simply fetched the binary and its dependencies. (I just gave nix-shell -p vagrant a try on a Mac M1 on channel 23.11 and it worked too.)

1 Like

Great! At least I know that there is a binary. Thanks a lot, that’ll help!

1 Like

To close the issue, it was apparently caused by a conflict with a local ruby gem, as suggested by this error.

Everything is great now, vagrant is cool. Thanks again @toraritte