{"record":{"id":"ab2004bd43656041","repo":"hashicorp/vagrant","slug":"this-command-was-not-invoked-properly-the-help-fo-ab2004","errorCode":null,"errorMessage":"This command was not invoked properly. The help for this command is available below. %{help}","messagePattern":"This command was not invoked properly\\. The help for this command is available below\\. %(.+?)","errorType":"exception","errorClass":"Vagrant::Errors::CLIInvalidUsage","httpStatus":null,"severity":"error","filePath":"plugins/commands/cloud/search.rb","lineNumber":57,"sourceCode":"            o.on(\"-l\", \"--limit LIMIT\", Integer, \"Max number of search results Default: 25\") do |l|\n              options[:limit] = l\n            end\n            o.on(\"-p\", \"--provider PROVIDER\", String, \"Filter search results to a single provider. Defaults to all.\") do |p|\n              options[:provider] = p\n            end\n            o.on(\"--sort-by SORT\", \"Field to sort results on (created, downloads, updated) Default: downloads\") do |s|\n              options[:sort] = s\n            end\n            o.on(\"--[no-]auth\", \"Authenticate with Vagrant Cloud if required before searching\") do |l|\n              options[:quiet] = !l\n            end\n          end\n\n          # Parse the options\n          argv = parse_options(opts)\n          return if !argv\n          if argv.length != 1\n            raise Vagrant::Errors::CLIInvalidUsage,\n              help: opts.help.chomp\n          end\n\n          @client = client_login(@env, options.slice(:quiet))\n          query = argv.first\n\n          options[:limit] = 25 if !(options[:limit].to_i < 1) && !options[:limit]\n\n          search(query, @client&.token, options)\n        end\n\n        # Perform requested search and display results to user\n        #\n        # @param [String] query Search query string\n        # @param [Hash] options\n        # @option options [String] :provider Filter by provider\n        # @option options [String] :sort Field to sort results\n        # @option options [Integer] :limit Number of results to display","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/commands/cloud/search.rb#L39-L75","documentation":"`vagrant cloud search` requires exactly one positional argument — the search query. Zero args or more than one raises CLIInvalidUsage. Because an unquoted multi-word query arrives as several argv entries, `vagrant cloud search ubuntu server` fails the `argv.length != 1` guard even though the intent was a single query.","triggerScenarios":"`vagrant cloud search` with no query; an unquoted multi-word query splitting into 2+ argv entries; flags placed after the query without their values being recognized; an empty $QUERY variable collapsing to zero args.","commonSituations":"Unquoted search strings — the most common cause; scripts passing \"$@\" instead of one quoted variable; assuming search behaves like `vagrant box search` of older releases.","solutions":["Quote the query: `vagrant cloud search \"ubuntu server\"`","Guard empty queries in scripts: `[ -n \"$QUERY\" ] && vagrant cloud search \"$QUERY\"`","Use options for everything else: --limit, --provider, --sort-by, --[no-]auth"],"exampleFix":"# before\nvagrant cloud search ubuntu server\n# after\nvagrant cloud search \"ubuntu server\"","handlingStrategy":"validation","validationCode":"# bash: require exactly one quoted query\nif [ \"$#\" -ne 1 ] || [ -z \"$1\" ]; then\n  echo \"usage: vagrant cloud search QUERY\" >&2\n  exit 64\nfi\nexec vagrant cloud search \"$@\"","typeGuard":null,"tryCatchPattern":"begin\n  env.cli(%w[cloud search], query)\nrescue Vagrant::Errors::CLIInvalidUsage => e\n  $stderr.puts e.message.lines.first\n  exit 64\nend","preventionTips":["Always quote search queries — multi-word input is the top cause of this error","Default an empty query variable to a deliberate value instead of passing nothing","In scripts pass one variable (\"$QUERY\"), never \"$@\", to search"],"tags":["vagrant","vagrant-cloud","cli","argument-validation","search"],"backgroundTag":"cli-invalid-usage","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}