hashicorp/vagrant · error · Vagrant::Errors::DarwinVersionFailed
Failed to determine macOS version. Version string: %{vers
Error message
Failed to determine macOS version.
Version string: %{version}
Error information: %{error} What it means
Vagrant::Errors::DarwinVersionFailed raised at plugins/hosts/darwin/cap/version.rb:11. The Darwin host capability resolves the macOS version by running `sw_vers -productVersion` through Vagrant::Util::Subprocess; if the command exits non-zero, Vagrant raises with %{version} = r.stdout and %{error} = r.stderr. This blocks every code path that dispatches on the host macOS version (SMB behavior, capability selection).
Source
Thrown at plugins/hosts/darwin/cap/version.rb:11
# Copyright IBM Corp. 2010, 2025
# SPDX-License-Identifier: BUSL-1.1
module VagrantPlugins
module HostDarwin
module Cap
class Version
def self.version(env)
r = Vagrant::Util::Subprocess.execute("sw_vers", "-productVersion")
if r.exit_code != 0
raise Vagrant::Errors::DarwinVersionFailed,
version: r.stdout,
error: r.stderr
end
begin
Gem::Version.new(r.stdout)
rescue => err
raise Vagrant::Errors::DarwinVersionFailed,
version: r.stdout,
error: err.message
end
end
end
end
end
end
View on GitHub (pinned to 35f3160f4a)
Solutions
- Run `/usr/bin/sw_vers -productVersion` in the same shell you launch Vagrant from and confirm it prints e.g. `14.5`
- Fix PATH so /usr/bin is present (`echo $PATH`), or launch vagrant from a normal Terminal session
- Remove any shell alias/function/shim that intercepts sw_vers
- If the binary itself is broken, repair macOS; otherwise update Vagrant
Defensive patterns
Strategy: validation
Validate before calling
raise "sw_vers unavailable on this host" unless system("/usr/bin/sw_vers -productVersion >/dev/null 2>&1")
# or from Ruby inside a plugin:
# Vagrant::Util::Subprocess.execute("/usr/bin/sw_vers", "-productVersion").exit_code.zero? Try / catch
begin
capability.call(:version, env)
rescue Vagrant::Errors::DarwinVersionFailed => e
puts "sw_vers failed: #{e.data[:error]}"
raise
end Prevention
- Launch vagrant from a normal Terminal session with /usr/bin on PATH
- In wrappers/IDE/CI, preserve a standard PATH instead of scrubbing it
- Don't alias or shim sw_vers
When it happens
Trigger: Any Vagrant operation needing the host macOS version executes `sw_vers -productVersion` in an environment where it fails: PATH scrubbed of /usr/bin (IDEs, wrappers, launchd contexts), the binary damaged, or a sandbox denying the spawn.
Common situations: Running Vagrant through an IDE/plugin with a minimal PATH; MDM/SIP restrictions; a repaired-but-broken OS install; scripts that alias or shadow sw_vers.
Related errors
- The executable '%{file}' Vagrant is trying to run was not fo
- Installation of the provider '%{provider}' failed! The stdou
- Failed to build iso image. The following command returned an
- The executable '%{file}' Vagrant is trying to run was not fo
- NFS is reporting that your exports file is invalid. Vagrant
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/b27cb78632e55f24.
Report an issue: GitHub.