How to fix "vagrant up" error "uninitialized constant VagrantPlugins::HostDarwin::Cap::Version"
Asked Answered
B

3

5

When doing vagrant up I get this error:

==> default: Exporting NFS shared folders...
Traceback (most recent call last):
    106: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'
    105: from /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/lib/vagrant/machine.rb:201:in `action'
.....

/opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/hosts/darwin/cap/path.rb:20:in `resolve_host_path': uninitialized constant VagrantPlugins::HostDarwin::Cap::Version (NameError)

I updated Vagrant and VirtualBox. How can I fix this?

Bandeen answered 22/1, 2022 at 18:56 Comment(1)
Solved it on my own: github.com/hashicorp/vagrant/issues/12583Bandeen
C
11

The solution is to run this command:

sudo curl -o /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/hosts/darwin/cap/path.rb https://raw.githubusercontent.com/hashicorp/vagrant/42db2569e32a69e604634462b633bb14ca20709a/plugins/hosts/darwin/cap/path.rb 

This command was found here.

Civilized answered 25/3, 2022 at 13:11 Comment(0)
I
1

I also had the same error:

uninitialized constant VagrantPlugins::HostDarwin::Cap::Version (NameError)

Downgrading Vagrant from 2.2.19 to 2.2.18 fixed it for me.

Intransigent answered 10/3, 2022 at 19:39 Comment(0)
E
0

Fixed vagrant 2.2.19 with this patch contributed to https://github.com/hashicorp/vagrant/issues/12583:

+ $ diff -u /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/hosts/darwin/cap/path.rb.backup-20220104 path.rb
--- /opt/vagrant/embedded/gems/2.2.19/gems/vagrant-2.2.19/plugins/hosts/darwin/cap/path.rb.backup-20220104  2022-01-04 12:35:09.000000000 +0100
+++ path.rb 2022-01-04 12:35:21.000000000 +0100
@@ -17,7 +17,8 @@
     def self.resolve_host_path(env, path)
       path = File.expand_path(path)
       # Only expand firmlink paths on Catalina
-          return path if !CATALINA_CONSTRAINT.satisfied_by?(Cap::Version.version(env))
+          host_version = env.host.capability(:version)
+          return path if !CATALINA_CONSTRAINT.satisfied_by?(host_version)

       firmlink = firmlink_map.detect do |mount_path, data_path|
         path.start_with?(mount_path)
Ern answered 30/6, 2022 at 11:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.