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

  1. Run `/usr/bin/sw_vers -productVersion` in the same shell you launch Vagrant from and confirm it prints e.g. `14.5`
  2. Fix PATH so /usr/bin is present (`echo $PATH`), or launch vagrant from a normal Terminal session
  3. Remove any shell alias/function/shim that intercepts sw_vers
  4. 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

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


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/b27cb78632e55f24. Report an issue: GitHub.