{"record":{"id":"c4150e7788050860","repo":"hashicorp/vagrant","slug":"the-vagrantfile-template-path-does-not-exist","errorCode":null,"errorMessage":"The Vagrantfile template '%{path}' does not exist. Please double check the template path and try again.","messagePattern":"The Vagrantfile template '%(.+?)' does not exist\\. Please double check the template path and try again\\.","errorType":"exception","errorClass":"Vagrant::Errors::VagrantfileTemplateNotFoundError","httpStatus":null,"severity":"error","filePath":"plugins/commands/init/command.rb","lineNumber":80,"sourceCode":"        # Determine the template and template root to use\n        template_root = \"\"\n        if options[:template].nil?\n          options[:template] = \"Vagrantfile\"\n\n          if options[:minimal]\n            options[:template] = \"Vagrantfile.min\"\n          end\n\n          template_root = ::Vagrant.source_root.join(\"templates/commands/init\")\n        end\n\n        # Strip the .erb extension off the template if the user passes it in\n        options[:template] = options[:template].chomp(\".erb\")\n\n        # Make sure the template actually exists\n        full_template_path = Vagrant::Util::TemplateRenderer.new(options[:template], template_root: template_root).full_template_path\n        if !File.file?(full_template_path)\n          raise Vagrant::Errors::VagrantfileTemplateNotFoundError, path: full_template_path\n        end\n\n        contents = Vagrant::Util::TemplateRenderer.render(options[:template],\n          box_name: argv[0] || \"base\",\n          box_url: argv[1],\n          box_version: options[:box_version],\n          template_root: template_root\n        )\n\n        if save_path\n          # Write out the contents\n          begin\n            save_path.open(\"w+\") do |f|\n              f.write(contents)\n            end\n          rescue Errno::EACCES\n            raise Vagrant::Errors::VagrantfileWriteError\n          end","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/init/command.rb#L62-L98","documentation":"`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}.","triggerScenarios":"`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).","commonSituations":"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).","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."],"exampleFix":"# before\nvagrant init --template templates/base.erb mybox   # run from the wrong cwd\n# after\nvagrant init --template /home/me/project/templates/base.erb mybox","handlingStrategy":"validation","validationCode":"tpl = File.expand_path(ARGV['--template']) rescue nil\nabort \"template not found: #{tpl}\" unless tpl && File.file?(tpl)\nsystem('vagrant', 'init', '--template', tpl, 'mybox')","typeGuard":null,"tryCatchPattern":"begin\n  Vagrant::Environment.new.cli(['init', '--template', tpl, 'mybox'])\nrescue Vagrant::Errors::VagrantfileTemplateNotFoundError => e\n  warn e.extra_data[:path] # the resolved path that failed\n  exit 1\nend","preventionTips":["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."],"tags":["vagrant","init","template","file-not-found"],"backgroundTag":"template-not-found","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}