hashicorp/vagrant · error · Vagrant::Errors::VagrantfileTemplateNotFoundError
The Vagrantfile template '%{path}' does not exist. Please do
Error message
The Vagrantfile template '%{path}' does not exist. Please double check the template path and try again. What it means
`vagrant init --template PATH` verifies the template resolves to a real file after stripping a trailing `.erb`. When a custom template is supplied, no template_root is set, so the path is interpreted as given (relative to the current working directory); only the built-in names Vagrantfile / Vagrantfile.min resolve against templates/commands/init. File.file? returning false raises Vagrant::Errors::VagrantfileTemplateNotFoundError with the resolved path in %{path}.
Source
Thrown at plugins/commands/init/command.rb:80
# Determine the template and template root to use
template_root = ""
if options[:template].nil?
options[:template] = "Vagrantfile"
if options[:minimal]
options[:template] = "Vagrantfile.min"
end
template_root = ::Vagrant.source_root.join("templates/commands/init")
end
# Strip the .erb extension off the template if the user passes it in
options[:template] = options[:template].chomp(".erb")
# Make sure the template actually exists
full_template_path = Vagrant::Util::TemplateRenderer.new(options[:template], template_root: template_root).full_template_path
if !File.file?(full_template_path)
raise Vagrant::Errors::VagrantfileTemplateNotFoundError, path: full_template_path
end
contents = Vagrant::Util::TemplateRenderer.render(options[:template],
box_name: argv[0] || "base",
box_url: argv[1],
box_version: options[:box_version],
template_root: template_root
)
if save_path
# Write out the contents
begin
save_path.open("w+") do |f|
f.write(contents)
end
rescue Errno::EACCES
raise Vagrant::Errors::VagrantfileWriteError
endView on GitHub (pinned to 35f3160f4a)
Solutions
- Verify the path from the directory you run vagrant in: `ls -l <path>`.
- Pass an absolute path: `vagrant init --template /abs/path/to/template <box>`.
- Drop --template to use the built-in Vagrantfile / Vagrantfile.min (with --minimal) templates.
Example fix
# before vagrant init --template templates/base.erb mybox # run from the wrong cwd # after vagrant init --template /home/me/project/templates/base.erb mybox
Defensive patterns
Strategy: validation
Validate before calling
tpl = File.expand_path(ARGV['--template']) rescue nil
abort "template not found: #{tpl}" unless tpl && File.file?(tpl)
system('vagrant', 'init', '--template', tpl, 'mybox') Try / catch
begin Vagrant::Environment.new.cli(['init', '--template', tpl, 'mybox']) rescue Vagrant::Errors::VagrantfileTemplateNotFoundError => e warn e.extra_data[:path] # the resolved path that failed exit 1 end
Prevention
- Pass absolute paths for custom templates.
- Remember init strips a trailing .erb before checking existence.
- Store project templates in a fixed location and reference them relative to the repo root.
When it happens
Trigger: `vagrant init --template my-template.erb box` where the file is not in the cwd; a typo'd or absolute path that does not exist; --template pointing at a directory (File.file? is false for directories).
Common situations: Running init from a different directory than where the template lives; templates referenced from a moved/renamed repo folder; .erb extension confusion (init strips it, so the on-disk name must still match after stripping).
Related errors
- The file you are attempting to upload does not exist. Please
- `Vagrantfile` already exists in this directory. Remove it be
- The license file to install could not be found. Please verif
- The source path provided for upload cannot be found. Please
- The validation key set for `config.chef.validation_key_path`
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/c4150e7788050860.
Report an issue: GitHub.