jdx/mise · error · RuntimeError

completion generation failed: #

Error message

completion generation failed: #{cmd.join(" ")}

What it means

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.

Solutions

  1. Run the completion command manually with the same args to see the underlying error.
  2. Update the formula's completion invocation/shell list to match what the tool supports.
  3. Fix the binary build so it runs (check missing shared libs with ldd/otool).
  4. For click tools, verify the derived env var (_NAME_COMPLETE) matches the tool's expected name.

Example fix

# before
bash_completions "mytool"
# after (tool now ships `mytool completions --shell`)
system bin/"mytool", "completions", "--shell", "bash"
bash_completion.install "completions.sh"
Defensive patterns

Strategy: try-catch

Try / catch

begin
  generate_completions(cmd, shell)
rescue RuntimeError => e
  raise unless e.message.start_with?("completion generation failed:")
  # run cmd manually; adjust shells or fix the binary
end

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/b5f5032276e6152f. Report an issue: GitHub.

Appendix: source

Thrown at src/system/packages/brew/shim.rb:853

    shells.each do |shell|
      completion_dir = { bash: bash_completion, zsh: zsh_completion, fish: fish_completion }.fetch(shell)
      file_name = { bash: base_name, zsh: "_#{base_name}", fish: "#{base_name}.fish" }.fetch(shell)
      shell_arg = case shell_parameter_format
                  when nil then shell.to_s
                  when :flag then "--#{shell}"
                  when :arg then "--shell=#{shell}"
                  when :none then nil
                  when :click then nil # click uses env vars; handled below
                  when String then "#{shell_parameter_format}#{shell}"
                  end
      cmd = commands.map(&:to_s)
      cmd << shell_arg unless shell_arg.nil?
      env = {}
      if shell_parameter_format == :click
        env["_#{base_name.upcase.tr("-", "_")}_COMPLETE"] = "#{shell}_source"
      end
      output, status = Open3.capture2(env, *cmd)
      raise "completion generation failed: #{cmd.join(" ")}" unless status.success?
      completion_dir.mkpath
      (completion_dir + file_name).write(output)
    end
  end

  def time = Time.now

  def post_install; end

  # unknown instance helpers: fail loudly
  def method_missing(name, *args, &block)
    shim_unsupported!("#{name} (install-time helper)")
  end

  def respond_to_missing?(_name, _include_private = false) = true

  class InreplaceText
    attr_reader :text

View on GitHub (pinned to 533346cc37)