{"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/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/brew/shim.rb#L835-L871","documentation":"The shim's completion generator builds a command to ask the tool itself to emit shell completions (including click-style env-var completion), runs it via Open3.capture2, and raises if the process exits non-zero. The generated output is then written into the completion directory.","triggerScenarios":"The tool's completion subcommand fails: wrong shell name passed, unsupported shell_parameter_format, tool version lacking the completion command, or the completion binary errors at runtime.","commonSituations":"Formula declaring shell_completion with a shell name the tool doesn't support (e.g. :nushell on older versions); click-based tools where the base_name-derived env var doesn't match the actual click program name; PATH issues during install.","solutions":["Run the completion command manually to see the tool's error output","Check the shell name is one the tool supports (bash/zsh/fish) and matches the installed tool version","For click tools, verify base_name matches the click program so the env var name is right","Update the formula to a tool version that supports the requested shell/format"],"exampleFix":"# before\nshell_completion :nushell, \"mytool\"\n# after\nshell_completion :bash, \"mytool\" # or :zsh/:fish, per tool support","handlingStrategy":"try-catch","validationCode":"# preflight: confirm the tool supports the shell\nsupported = %w[bash zsh fish]\nraise \"unsupported shell #{shell}\" unless supported.include?(shell.to_s)","typeGuard":null,"tryCatchPattern":"begin\n  generate_completions(shell)\nrescue RuntimeError => e\n  raise unless e.message.start_with?(\"completion generation failed\")\n  warn \"completion generation failed for #{shell}: #{e.message}\"\nend","preventionTips":["Confirm the installed tool version supports the requested shell","For click tools, keep base_name aligned with the click program name","Run the tool's completion command manually when a formula install fails here"],"tags":["completions","subprocess","ruby"],"backgroundTag":"completion-generation-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}