hashicorp/vagrant · error · VagrantPlugins::DockerProvider::Errors::VagrantfileNotFound
The configured host VM Vagrantfile could not be found. Pleas
Error message
The configured host VM Vagrantfile could not be found. Please fix the Vagrantfile for this Docker environment to point to a valid host VM.
What it means
The Docker provider builds a separate Vagrant::Environment for the host VM from provider_config.vagrant_vagrantfile (expanded against the main project root; when unset, a default Vagrantfile is copied into the data dir). If that environment ends with no root_path - no Vagrantfile with the expected filename found at that path - VagrantfileNotFound is raised.
Source
Thrown at plugins/providers/docker/provider.rb:106
# Expand it so that the home directories and so on get processed
# properly.
vf_path = File.expand_path(vf_path, @machine.env.root_path)
vf_file = File.basename(vf_path)
vf_path = File.dirname(vf_path)
# Create the env to manage this machine
@host_vm = Vagrant::Util::SilenceWarnings.silence! do
host_env = Vagrant::Environment.new(
cwd: vf_path,
home_path: @machine.env.home_path,
ui_class: @machine.env.ui_class,
vagrantfile_name: vf_file,
)
# If there is no root path, then the Vagrantfile wasn't found
# and it is an error...
raise Errors::VagrantfileNotFound if !host_env.root_path
host_env.machine(
host_machine_name,
host_env.default_provider(
exclude: [:docker],
force_default: false,
))
end
@host_vm
end
# This acquires a lock on the host VM.
def host_vm_lock
hash = Digest::MD5.hexdigest(host_vm.data_dir.to_s)
# We do a process-level mutex on the outside, since we can
# wait for that a short amount of time. Then, we do a process lockView on GitHub (pinned to 35f3160f4a)
Solutions
- Fix d.vagrant_vagrantfile to an existing Vagrantfile - relative paths resolve from the main project root, e.g. "./host-vm/Vagrantfile"
- If you do not need a custom host VM, remove the option so the built-in default Vagrantfile is used
- Commit or template the host VM Vagrantfile so every checkout has it
Example fix
# before config.vm.provider "docker" do |d| d.vagrant_vagrantfile = "./host-vm" # directory without a Vagrantfile end # after config.vm.provider "docker" do |d| d.vagrant_vagrantfile = "./host-vm/Vagrantfile" # actual file end
Defensive patterns
Strategy: validation
Validate before calling
# inside the Vagrantfile, fail fast with a clear message
host_vf = File.expand_path("./host-vm/Vagrantfile", __dir__)
unless File.file?(host_vf)
raise "host VM Vagrantfile missing: #{host_vf}"
end
config.vm.provider "docker" do |d|
d.vagrant_vagrantfile = host_vf
end Prevention
- Commit host VM Vagrantfiles to version control
- Prefer paths relative to the main Vagrantfile, never machine-specific absolute paths
- Validate custom host VM paths in a wrapper script before invoking vagrant
When it happens
Trigger: d.vagrant_vagrantfile pointing at a missing file, a directory without a Vagrantfile, or a wrong file name (vagrantfile_name is taken from the basename); relative paths that do not resolve against the main Vagrantfile's directory.
Common situations: Project moved or renamed after configuring a host VM Vagrantfile; the path not committed to version control so teammates hit it; absolute paths copied from another machine.
Related errors
- The Docker provider was able to bring up the host VM success
- A Docker command executed by Vagrant didn't complete success
- Warning: When using a remote Docker host, forwarded ports wi
- Multiple URLs for a box can't be specified when adding versi
- There are errors in the configuration of this machine. Pleas
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/4285843739b4ef7c.
Report an issue: GitHub.