hashicorp/vagrant · error · VagrantPlugins::Chef::Provisioner::Base::ChefError

Vagrant could not detect Chef on the guest! Even after Vagra

Error message

Vagrant could not detect Chef on the guest! Even after Vagrant
attempted to install Chef, it could still not find Chef on the system.
Please make sure you are connected to the Internet and can access
Chef's package distribution servers. If you already have Chef
installed on this guest, you can disable the automatic Chef detection
by setting the 'install' option in the Chef configuration section of
your Vagrantfile:

    chef.install = false

What it means

Raised by the Chef installer after it decided Chef was missing (or `force` was set), ran the guest `chef_install` capability, and the follow-up `chef_installed` capability check still reports the requested product/version is absent. The install attempt itself already streamed its output; this error only says the post-install verification failed. Typical root causes are network/package-repository failures inside the guest, unsupported distros, or a version string the verification check cannot satisfy.

Source

Thrown at plugins/provisioners/chef/installer.rb:39

        # If the guest cannot check if Chef is installed, just exit printing a
        # warning...
        if !@machine.guest.capability?(:chef_installed)
          @machine.ui.warn(I18n.t("vagrant.chef_cant_detect"))
          return
        end

        if !should_install_chef?
          @machine.ui.info(I18n.t("vagrant.chef_already_installed",
            version: @version.to_s))
          return
        end

        @machine.ui.detail(I18n.t("vagrant.chef_installing",
          version: @version.to_s))
        @machine.guest.capability(:chef_install, @product, @version, @channel, @omnibus_url, @options)

        if !@machine.guest.capability(:chef_installed, @product, @version)
          raise Provisioner::Base::ChefError, :install_failed
        end
      end

      # Determine if Chef should be installed. Chef is installed if the "force"
      # option is given or if the guest does not have Chef installed at the
      # proper version.
      def should_install_chef?
        @force || !@machine.guest.capability(:chef_installed, @product, @version)
      end
    end
  end
end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Scroll up to the installer output - it shows the actual download/package error from the guest
  2. Verify guest egress: `vagrant ssh` then `curl -I https://omnitruck.chef.io` (or your proxy settings work)
  3. If Chef really is preinstalled in the box, disable detection+install: `chef.install = false`
  4. Pin a known-good product/version: `chef.product = "chef"` and `chef.version = "17.10.0"` instead of :latest

Example fix

# Vagrantfile - before
config.vm.provision "chef_solo" do |chef|
  chef.version = :latest
end

# Vagrantfile - after
config.vm.provision "chef_solo" do |chef|
  chef.install = false   # Chef already baked into the box
end
Defensive patterns

Strategy: try-catch

Validate before calling

# Vagrantfile: skip detection when the box already ships Chef
if ENV["CHEF_PREINSTALLED"]
  chef.install = false
end

Try / catch

begin
  env.cli(%w[up --provision])
rescue Vagrant::Errors::VagrantError => e
  if e.message.include?("could not detect Chef")
    retry_after_network_fix!
  else
    raise
  end
end

Prevention

When it happens

Trigger: Calling any chef provisioner (chef_solo/chef_zero/chef_client) with `install` enabled (default true) where `should_install_chef?` is true, `@machine.guest.capability(:chef_install, ...)` runs, and `chef_installed` afterwards still returns false.

Common situations: Air-gapped or proxied environments where packagecloud/chef.io downloads fail inside the guest; unsupported or very new distro release with no install script; requested `version` string never matches what omnitruck installs; slow mirrors timing out.

Related errors


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