hashicorp/vagrant · error · Vagrant::Errors::PackageOutputDirectory
The specified output is a directory. Please specify a path i
Error message
The specified output is a directory. Please specify a path including a filename.
What it means
Package validates that the --output path names a file, not a directory: PackageOutputDirectory is raised when the expanded output path is an existing directory (checked both in validate! and again in call after folder handling). The fix is always to include a filename component in the output path.
Source
Thrown at lib/vagrant/action/general/package.rb:82
def initialize(app, env)
@app = app
env["package.files"] ||= {}
env["package.info"] ||= ""
env["package.output"] ||= "package.box"
@fullpath = self.class.fullpath(env["package.output"])
end
def call(env)
@env = env
self.class.validate!(env["package.output"], env["package.directory"])
package_with_folder_path if env["package.output"].include?(File::SEPARATOR)
raise Errors::PackageOutputDirectory if File.directory?(fullpath)
raise Errors::PackageInvalidInfo if invalid_info?
@app.call(env)
@env[:ui].info I18n.t("vagrant.actions.general.package.compressing", fullpath: fullpath)
copy_include_files
copy_info
setup_private_key
write_metadata_json
compress
end
def package_with_folder_path
folder_path = File.expand_path("..", @fullpath)
create_box_folder(folder_path) unless File.directory?(folder_path)
endView on GitHub (pinned to 35f3160f4a)
Solutions
- Append a filename: `vagrant package --output boxes/myapp.box`.
- If you wanted a clean name each time, combine folder + timestamped filename: `--output "boxes/myapp-$(date +%s).box"`.
Example fix
# before vagrant package --output ./boxes/ # boxes/ is a directory => error # after vagrant package --output ./boxes/myapp.box # parent folders are auto-created
Defensive patterns
Strategy: validation
Validate before calling
# Shell: reject directory outputs before invoking vagrant package
out="${PACKAGE_OUT:-package.box}"
[ -d "$out" ] && { echo "--output must include a filename, got directory: $out"; exit 1; }
vagrant package --output "$out" Prevention
- Always pass a full file path (dir + filename) to --output; Vagrant creates missing parent directories for you.
- In shared scripts, build the value as "${DIR}/${NAME}.box" so a filename is always appended.
When it happens
Trigger: Running `vagrant package --output ./boxes/` or `--output /tmp` where that path is a directory (lib/vagrant/action/general/package.rb:40-42 and :82). Note: parent directories in an output path are fine — Vagrant creates missing folders via package_with_folder_path; only the final segment must not be an existing directory.
Common situations: Passing a target folder instead of a file when scripting packaging; copy-pasting an --output value that was a directory in another workflow; muscle memory from commands like `tar -C dir`.
Related errors
- The specified file '%{filename}' to save the package as alre
- The information file that you've attempted to include doesn'
- Package include file doesn't exist: %{file}
- The Vagrant virtual environment you are trying to package mu
- The box you're using with the Hyper-V provider ('%{name}') i
AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21).
Data as JSON: /api/errors/52c3080e570ebd7c.
Report an issue: GitHub.