ruby/rubygems · error · Gem::InstallError

#{spec} has an invalid bindir

Error message

#{spec} has an invalid bindir

What it means

Error "#{spec} has an invalid bindir" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/installer.rb:720

    end

    unless /\A\d+\z/.match?(spec.specification_version.to_s)
      raise Gem::InstallError, "#{spec} has an invalid specification_version"
    end

    if spec.dependencies.any? {|dep| dep.type != :runtime && dep.type != :development }
      raise Gem::InstallError, "#{spec} has an invalid dependencies"
    end

    if spec.dependencies.any? {|dep| dep.name =~ /(?:\R|[<>])/ }
      raise Gem::InstallError, "#{spec} has an invalid dependencies"
    end

    if spec.executables.any? {|name| !name.is_a?(String) || name != File.basename(name) || /\A\.\.?\z|\R/.match?(name) }
      raise Gem::InstallError, "#{spec} has an invalid executable"
    end

    raise Gem::InstallError, "#{spec} has an invalid bindir" unless spec.bindir.is_a?(String)

    expanded_gem_dir = File.expand_path(gem_dir)
    expanded_bindir = File.expand_path(File.join(gem_dir, spec.bindir))
    unless expanded_bindir == expanded_gem_dir || expanded_bindir.start_with?("#{expanded_gem_dir}/")
      raise Gem::InstallError, "#{spec} has an invalid bindir"
    end
  end

  ##
  # Return the text for an application file.

  def app_script_text(bin_file_name)
    # NOTE: that the `load` lines cannot be indented, as old RG versions match
    # against the beginning of the line
    escaped_bin_file_name = bin_file_name.gsub(/[\\']/) {|c| "\\#{c}" }
    <<~TEXT
      #{shebang bin_file_name}
      #

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Set `spec.bindir` to an existing directory containing the executables (default: 'bin')

When it happens

Trigger: Thrown at lib/rubygems/installer.rb:720 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23). Data as JSON: /api/errors/f01c6d0b67090792. Report an issue: GitHub.