{"record":{"id":"c38f60a211f4b561","repo":"hashicorp/vagrant","slug":"vagrant-commands-box-no-installed-boxes","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/list.rb","lineNumber":30,"sourceCode":"\n          opts = OptionParser.new do |o|\n            o.banner = \"Usage: vagrant box list [options]\"\n            o.separator \"\"\n            o.separator \"Options:\"\n            o.separator \"\"\n\n            o.on(\"-i\", \"--box-info\", \"Displays additional information about the boxes\") do |i|\n              options[:info] = i\n            end\n          end\n\n          # Parse the options\n          argv = parse_options(opts)\n          return if !argv\n\n          boxes = @env.boxes.all\n          if boxes.empty?\n            @env.ui.warn(I18n.t(\"vagrant.commands.box.no_installed_boxes\"), prefix: false)\n            return 0\n          end\n\n          list_boxes(boxes, options[:info])\n\n          # Success, exit status 0\n          0\n        end\n\n        private\n\n        def list_boxes(boxes, extra_info)\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          # Group boxes by name and version and start iterating\n          boxes.group_by { |b| [b[0], b[1]] }.each do |box_info, box_data|","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/box/command/list.rb#L12-L48","documentation":"Warning from `vagrant box list` (plugins/commands/box/command/list.rb) when @env.boxes.all returns an empty collection — i.e. the global boxes directory (~/.vagrant.d/boxes) contains no installed boxes. It prints 'There are no installed boxes! Use `vagrant box add` to add some.' and the command exits with status 0, not an error.","triggerScenarios":"Running `vagrant box list` (with or without -i/--box-info) on a fresh install, with VAGRANT_HOME pointed at an empty/new directory, or after `vagrant box prune`/`box remove` removed the last box.","commonSituations":"Fresh machines or CI containers with no prior `vagrant box add`; a mis-set VAGRANT_HOME/VAGRANT_DOTFILE_PATH environment variable making Vagrant look in an unexpected directory; scripts that parse `vagrant box list` output and get confused by the warning text instead of empty output.","solutions":["If you expected boxes to exist, check VAGRANT_HOME (`echo $VAGRANT_HOME`) and list the actual directory (`ls ${VAGRANT_HOME:-~/.vagrant.d}/boxes`).","Add a box first: `vagrant box add --provider virtualbox <name-or-url>`, or just run `vagrant up` which auto-downloads the Vagrantfile's box.","If scripting around this, rely on the exit status (0) rather than output, or use `vagrant box list --format json`-style machine-readable handling instead of parsing the warning."],"exampleFix":"# before (script assumes boxes exist)\nBOXES=$(vagrant box list | wc -l)\n\n# after (script tolerates the empty-collection warning)\nvagrant box add generic/ubuntu2004 || exit 1\nBOXES=$(vagrant box list | grep -c '^' || true)","handlingStrategy":"validation","validationCode":"# Before scripting against box state\nboxes_dir = File.join(ENV['VAGRANT_HOME'] || File.join(Dir.home, '.vagrant.d'), 'boxes')\nhas_boxes = Dir.children(boxes_dir).any? { |d| File.directory?(File.join(boxes_dir, d)) }\nabort 'no boxes installed' unless has_boxes","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In shell scripts, branch on `vagrant box list` output being non-empty before parsing it.","Set VAGRANT_HOME explicitly in automation so the boxes directory is deterministic.","Remember `vagrant box list` returns exit 0 with this warning — key logic on output/exit, not absence of warnings."],"tags":["vagrant","box-management","empty-state","cli"],"backgroundTag":"empty-result-set","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}