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)
        end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Append a filename: `vagrant package --output boxes/myapp.box`.
  2. 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

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


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