{"record":{"id":"0c164ceab506b113","repo":"hashicorp/vagrant","slug":"vagrant-commands-box-no-installed-boxes-0c164c","errorCode":null,"errorMessage":"vagrant.commands.box.no_installed_boxes","messagePattern":"vagrant\\.commands\\.box\\.no_installed_boxes","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"plugins/commands/box/command/prune.rb","lineNumber":48,"sourceCode":"              options[:name] = name\n            end\n\n            o.on(\"-f\", \"--force\", \"Destroy without confirmation even when box is in use.\") do |f|\n              options[:force] = f\n            end\n\n            o.on(\"-k\", \"--keep-active-boxes\", \"When combined with `--force`, will keep boxes still actively in use.\") do |k|\n              options[:keep] = k\n            end\n          end\n\n          # Parse the options\n          argv = parse_options(opts)\n          return if !argv\n\n          boxes = @env.boxes.all.sort\n          if boxes.empty?\n            return @env.ui.warn(I18n.t(\"vagrant.commands.box.no_installed_boxes\"), prefix: false)\n          end\n\n          delete_oldest_boxes(boxes, options[:provider], options[:force], options[:name], options[:dry_run], options[:keep])\n\n          # Success, exit status 0\n          0\n        end\n\n        private\n\n        def delete_oldest_boxes(boxes, only_provider, skip_confirm, only_name, dry_run, keep_used_boxes)\n          # Find the longest box name\n          longest_box = boxes.max_by { |x| x[0].length }\n          longest_box_length = longest_box[0].length\n\n          # Hash map to keep track of newest versions\n          newest_boxes = Hash.new\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/box/command/prune.rb#L30-L66","documentation":"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).","triggerScenarios":"Running `vagrant box prune` (with any flags such as --provider, --dry-run, --keep-active-boxes) on an environment where the boxes collection is empty.","commonSituations":"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.","solutions":["Treat it as benign: if no boxes are installed there is nothing to prune; verify with `vagrant box list`.","If you expected boxes, check VAGRANT_HOME and inspect ${VAGRANT_HOME:-~/.vagrant.d}/boxes.","In automation, guard the call: only run `vagrant box prune` when `vagrant box list` is non-empty, to keep logs clean."],"exampleFix":"# before (CI cleanup step)\n- run: vagrant box prune --force\n\n# after (guarded)\n- run: |\n    if [ -n \"$(vagrant box list)\" ]; then\n      vagrant box prune --force\n    else\n      echo \"no boxes to prune\"\n    fi","handlingStrategy":"validation","validationCode":"if [ -n \"$(vagrant box list 2>/dev/null)\" ]; then\n  vagrant box prune --force\nelse\n  echo \"skip: no installed boxes\"\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard prune in cron/CI with an emptiness check to keep logs clean.","Verify VAGRANT_HOME before concluding boxes are missing.","Treat the warning plus missing `0` return as a no-op success, not a failure."],"tags":["vagrant","box-management","empty-state","prune"],"backgroundTag":"empty-result-set","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}