{"record":{"id":"9e0b7bee302e232a","repo":"hashicorp/vagrant","slug":"no-virtual-machines-matched-the-regular-expression-9e0b7b","errorCode":null,"errorMessage":"No virtual machines matched the regular expression given.","messagePattern":"No virtual machines matched the regular expression given\\.","errorType":"exception","errorClass":"Vagrant::Errors::VMNoMatchError","httpStatus":null,"severity":"error","filePath":"lib/vagrant/plugin/v2/command.rb","lineNumber":203,"sourceCode":"\n          # First determine the proper array of VMs.\n          machines = []\n          if names.length > 0\n            names.each do |name|\n              if pattern = name[/^\\/(.+?)\\/$/, 1]\n                @logger.debug(\"Finding machines that match regex: #{pattern}\")\n\n                # This is a regular expression name, so we convert to a regular\n                # expression and allow that sort of matching.\n                regex = Regexp.new(pattern)\n\n                @env.machine_names.each do |machine_name|\n                  if machine_name =~ regex\n                    machines << get_machine.call(machine_name)\n                  end\n                end\n\n                raise Errors::VMNoMatchError if machines.empty?\n              else\n                # String name, just look for a specific VM\n                @logger.debug(\"Finding machine that match name: #{name}\")\n                machines << get_machine.call(name.to_sym)\n                raise Errors::VMNotFoundError, name: name if !machines[0]\n              end\n            end\n          else\n            # No name was given, so we return every VM in the order\n            # configured.\n            @logger.debug(\"Loading all machines...\")\n            machines = @env.machine_names.map do |machine_name|\n              get_machine.call(machine_name)\n            end\n          end\n\n          @logger.debug(\"have machine list to process\")\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/lib/vagrant/plugin/v2/command.rb#L185-L221","documentation":"v2 counterpart of the v1 regex error: a slash-delimited target (`vagrant <cmd> /pattern/`) was compiled and matched against env.machine_names, and no configured machine name matched, so the guard at lib/vagrant/plugin/v2/command.rb:203 raised before any machine was yielded. The pattern is plain Ruby Regexp, unanchored by default.","triggerScenarios":"`vagrant up /app-/` in a project whose machines are named web and db; a pattern written for full names when defines use hyphenated names; a regex with an escaping mistake that matches nothing.","commonSituations":"Machine names refactored after the pattern was written; patterns copied between projects; assuming anchoring semantics that were never specified.","solutions":["List valid machine names via `vagrant status` or the config.vm.define blocks","Fix and anchor the pattern explicitly, e.g. /^web-/","Use exact machine names in scripts; keep regex selectors for interactive use"],"exampleFix":"# before (machines are web-1, web-2)\nvagrant destroy /^webserver/\n\n# after\nvagrant destroy /^web-/","handlingStrategy":"validation","validationCode":"pattern = \"^web-\"\nnames = env.machine_names.map(&:to_s)\nabort \"no machine matches /#{pattern}/; valid: #{names.join(', ')}\" unless names.any? { |n| n =~ /#{pattern}/ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Anchor regex selectors (/^web-/) rather than relying on substring matching","Verify machine names with `vagrant status` after refactoring a Vagrantfile","Prefer exact names in automation; use regex selectors interactively"],"tags":["cli","regex","machine-selection","v2-plugins"],"backgroundTag":"regex-pattern-no-match","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}