{"record":{"id":"b5f5032276e6152f","repo":"jdx/mise","slug":"completion-generation-failed-cmd-join","errorCode":null,"errorMessage":"completion generation failed: #{cmd.join(\" \")}","messagePattern":"completion generation failed: #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":853,"sourceCode":"    shells.each do |shell|\n      completion_dir = { bash: bash_completion, zsh: zsh_completion, fish: fish_completion }.fetch(shell)\n      file_name = { bash: base_name, zsh: \"_#{base_name}\", fish: \"#{base_name}.fish\" }.fetch(shell)\n      shell_arg = case shell_parameter_format\n                  when nil then shell.to_s\n                  when :flag then \"--#{shell}\"\n                  when :arg then \"--shell=#{shell}\"\n                  when :none then nil\n                  when :click then nil # click uses env vars; handled below\n                  when String then \"#{shell_parameter_format}#{shell}\"\n                  end\n      cmd = commands.map(&:to_s)\n      cmd << shell_arg unless shell_arg.nil?\n      env = {}\n      if shell_parameter_format == :click\n        env[\"_#{base_name.upcase.tr(\"-\", \"_\")}_COMPLETE\"] = \"#{shell}_source\"\n      end\n      output, status = Open3.capture2(env, *cmd)\n      raise \"completion generation failed: #{cmd.join(\" \")}\" unless status.success?\n      completion_dir.mkpath\n      (completion_dir + file_name).write(output)\n    end\n  end\n\n  def time = Time.now\n\n  def post_install; end\n\n  # unknown instance helpers: fail loudly\n  def method_missing(name, *args, &block)\n    shim_unsupported!(\"#{name} (install-time helper)\")\n  end\n\n  def respond_to_missing?(_name, _include_private = false) = true\n\n  class InreplaceText\n    attr_reader :text","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/shim.rb#L835-L871","documentation":"The shim's completion generator runs the tool's own completion command (e.g. `<tool> --completions <shell>`, or click-style via env var) and raises when the subprocess reports non-zero exit, aborting completion file generation.","triggerScenarios":"Installing a formula whose completions step invokes the built binary for completion output but the binary crashes, doesn't support the requested shell, or mis-parses the shell_parameter_format (e.g. click env-var handshake).","commonSituations":"Newly built binary broken or dynamically linking against missing libs; tool dropped support for a shell (e.g. fish/zsh) the formula still requests; click-based tools whose `_TOOL_COMPLETE` env name no longer matches.","solutions":["Run the completion command manually with the same args to see the underlying error.","Update the formula's completion invocation/shell list to match what the tool supports.","Fix the binary build so it runs (check missing shared libs with ldd/otool).","For click tools, verify the derived env var (_NAME_COMPLETE) matches the tool's expected name."],"exampleFix":"# before\nbash_completions \"mytool\"\n# after (tool now ships `mytool completions --shell`)\nsystem bin/\"mytool\", \"completions\", \"--shell\", \"bash\"\nbash_completion.install \"completions.sh\"","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  generate_completions(cmd, shell)\nrescue RuntimeError => e\n  raise unless e.message.start_with?(\"completion generation failed:\")\n  # run cmd manually; adjust shells or fix the binary\nend","preventionTips":["Verify the completion subcommand/shells in the tool's docs each release","Smoke-test the built binary before running completion generation","Confirm click tools' _NAME_COMPLETE env naming convention","Keep the formula's shell list in sync with tool support"],"tags":["ruby","brew-shim","completions","subprocess"],"backgroundTag":"command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}