hashicorp/vagrant · warning

vagrant.commands.box.no_installed_boxes

Error message

vagrant.commands.box.no_installed_boxes

What it means

Warning from `vagrant box prune` (plugins/commands/box/command/prune.rb) when @env.boxes.all.sort is empty — there are no installed boxes at all, so there is nothing to prune. It prints the shared 'There are no installed boxes!' message with prefix: false and returns the ui.warn return value (the command then ends without reaching the success 0 line, though the warn itself is not an exception).

Source

Thrown at plugins/commands/box/command/prune.rb:48

              options[:name] = name
            end

            o.on("-f", "--force", "Destroy without confirmation even when box is in use.") do |f|
              options[:force] = f
            end

            o.on("-k", "--keep-active-boxes", "When combined with `--force`, will keep boxes still actively in use.") do |k|
              options[:keep] = k
            end
          end

          # Parse the options
          argv = parse_options(opts)
          return if !argv

          boxes = @env.boxes.all.sort
          if boxes.empty?
            return @env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), prefix: false)
          end

          delete_oldest_boxes(boxes, options[:provider], options[:force], options[:name], options[:dry_run], options[:keep])

          # Success, exit status 0
          0
        end

        private

        def delete_oldest_boxes(boxes, only_provider, skip_confirm, only_name, dry_run, keep_used_boxes)
          # Find the longest box name
          longest_box = boxes.max_by { |x| x[0].length }
          longest_box_length = longest_box[0].length

          # Hash map to keep track of newest versions
          newest_boxes = Hash.new

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Treat it as benign: if no boxes are installed there is nothing to prune; verify with `vagrant box list`.
  2. If you expected boxes, check VAGRANT_HOME and inspect ${VAGRANT_HOME:-~/.vagrant.d}/boxes.
  3. In automation, guard the call: only run `vagrant box prune` when `vagrant box list` is non-empty, to keep logs clean.

Example fix

# before (CI cleanup step)
- run: vagrant box prune --force

# after (guarded)
- run: |
    if [ -n "$(vagrant box list)" ]; then
      vagrant box prune --force
    else
      echo "no boxes to prune"
    fi
Defensive patterns

Strategy: validation

Validate before calling

if [ -n "$(vagrant box list 2>/dev/null)" ]; then
  vagrant box prune --force
else
  echo "skip: no installed boxes"
fi

Prevention

When it happens

Trigger: Running `vagrant box prune` (with any flags such as --provider, --dry-run, --keep-active-boxes) on an environment where the boxes collection is empty.

Common situations: Cleanup cron jobs or CI cleanup steps running prune on fresh containers; VAGRANT_HOME pointing to a fresh directory so previously pruned state is invisible; running prune right after removing the last box manually.

Related errors


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