ruby/rubygems · error · Gem::OptionParser::InvalidArgument

cannot find gem dependencies file #{message}

Error message

cannot find gem dependencies file #{message}

What it means

Error "cannot find gem dependencies file #{message}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/install_update_options.rb:158

      options[:minimal_deps] = value
    end

    add_option(:"Install/Update", "--[no-]post-install-message",
                "Print post install message") do |value, options|
      options[:post_install_message] = value
    end

    add_option(:"Install/Update", "-g", "--file [FILE]",
               "Read from a gem dependencies API file and",
               "install the listed gems") do |v,_o|
      v ||= Gem::GEM_DEP_FILES.find do |file|
        File.exist? file
      end

      unless v
        message = v ? v : "(tried #{Gem::GEM_DEP_FILES.join ", "})"

        raise Gem::OptionParser::InvalidArgument,
                "cannot find gem dependencies file #{message}"
      end

      options[:gemdeps] = v
    end

    add_option(:"Install/Update", "--without GROUPS", Array,
               "Omit the named groups (comma separated)",
               "when installing from a gem dependencies",
               "file") do |v,_o|
      options[:without_groups].concat v.map(&:intern)
    end

    add_option(:Deprecated, "--default",
               "Add the gem's full specification to",
               "specifications/default and extract only its bin") do |v,_o|
    end

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Pass an existing dependencies file: `gem install -g /path/to/Gemfile`
  2. Create the Gemfile/gemspec the option points at, or fix the path typo

When it happens

Trigger: Thrown at lib/rubygems/install_update_options.rb:158 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/4395f08c820a2e9d. Report an issue: GitHub.