Skip to content

Valid gems with long dependency requirements cannot be pushed #5541

Open
@Fryguy

Description

@Fryguy

This was a new one for me, but I wanted to limit my gem to specific versions of rack to avoid the most recent CVE there, while still allowing the latest of the 2.2, 3.0, or 3.1 y-streams (Since I don't know what callers will need which version of rack - I'm looking at you Rails 7.0).

Since there's no "OR" or "range" syntax for the gem requirements that I'm aware of, I built the following in my gemspec (It's gross, I know, I don't know what else to do 😆).

# Enforce a minimum of 2.2.13, 3.0.14, or 3.1.12 for CVE-2025-27610
spec.add_runtime_dependency "rack", ">= 2.2.13", *("!= 3.0.0".."!= 3.0.9"), "!= 3.0.4.1",
  "!= 3.0.4.2", "!= 3.0.6.1", "!= 3.0.9.1", *("!= 3.0.10".."!= 3.0.13"), *("!= 3.1.0".."!= 3.1.9"),
  *("!= 3.1.10".."!= 3.1.11"), "< 4"

This is functionally equivalent to, but visually shorter than:

spec.add_runtime_dependency "rack", ">= 2.2.13", "!= 3.0.0", "!= 3.0.1", "!= 3.0.2",
  "!= 3.0.3", "!= 3.0.4", "!= 3.0.5", "!= 3.0.6", "!= 3.0.7", "!= 3.0.8", "!= 3.0.9", "!= 3.0.4.1",
  "!= 3.0.4.2", "!= 3.0.6.1", "!= 3.0.9.1", "!= 3.0.10", "!= 3.0.11", "!= 3.0.12", "!= 3.0.13",
  "!= 3.1.0", "!= 3.1.1", "!= 3.1.2", "!= 3.1.3", "!= 3.1.4", "!= 3.1.5", "!= 3.1.6", "!= 3.1.7",
  "!= 3.1.8", "!= 3.1.9", "!= 3.1.10", "!= 3.1.11", "< 4"

Everything works fine...bundler works fine, bundler references to this via git or path work fine (which is how I tested it), and gem build works fine. However, on gem push I get the error:

There was a problem saving your gem: Dependency requirements is too long (maximum is 255 characters)

Steps to Reproduce

  1. See above and create a simple gemspec with the spec above, build it, and try to push it.

Expected Behavior

I didn't expect a valid gem to not be able to be pushed to rubygems.org. If there needs to be a length limit on the dependency requirements, that's understandable, however then I would have expected gem build to also fail with the same error (or at least give a warning). Conversely, it feels like anything that's buildable with gem build should be pushable to rubygems.org.

Current Behavior

gem push yields

There was a problem saving your gem: Dependency requirements is too long (maximum is 255 characters)

Possible Solution

I don't know the reason for the specific 255 character max limit, but maybe we can open that up a bit? I guess if you have to have a limit, then you can't make everyone happy, but perhaps 512 or 1024?

Additionally, a warning or straight up error on the rubygems build side would be helpful to avoid getting into this situation.

Alternatively, an OR syntax or a range syntax would help solve my particular situation because I wouldn't have to create this long list of individual fields to begin with.

Environment

Browser and its version:
RubyGems version: 3.5.22
Ruby: ruby 3.3.7 (2025-01-15 revision be31f993d7) [arm64-darwin23]

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions