ruby/rubygems · error · ArgumentError

invalid gemspec #{spec_file}

Error message

invalid gemspec #{spec_file}

What it means

Error "invalid gemspec #{spec_file}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/request_set/gem_dependency_api.rb:260

  private :add_dependencies

  ##
  # Finds a gemspec with the given +name+ that lives at +path+.

  def find_gemspec(name, path) # :nodoc:
    glob = File.join path, "#{name}.gemspec"

    spec_files = Dir[glob]

    case spec_files.length
    when 1 then
      spec_file = spec_files.first

      spec = Gem::Specification.load spec_file

      return spec if spec

      raise ArgumentError, "invalid gemspec #{spec_file}"
    when 0 then
      raise ArgumentError, "no gemspecs found at #{Dir.pwd}"
    else
      raise ArgumentError,
        "found multiple gemspecs at #{Dir.pwd}, " \
        "use the name: option to specify the one you want"
    end
  end

  ##
  # Changes the behavior of gem dependency file loading to installing mode.
  # In installing mode certain restrictions are ignored such as ruby version
  # mismatch checks.

  def installing=(installing) # :nodoc:
    @installing = installing
  end

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Fix the named gemspec file so it evaluates to a valid Gem::Specification

When it happens

Trigger: Thrown at lib/rubygems/request_set/gem_dependency_api.rb:260 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/685c651395c83fb7. Report an issue: GitHub.