Skip to content

bundler Add cannot update a gemspec-declared dependency constraint #40

Description

@andrew

A publishable gem declares its dependency constraints in the .gemspec:

s.add_dependency "foo", "~> 1.0"

Manager.Add(ctx, "foo", AddOptions{Version: "2.0"}) for the bundler definition runs bundle add foo --version 2.0, which appends to Gemfile. The published constraint in the gemspec is unchanged, and if the gem was already in the Gemfile via a gemspec directive, bundle add fails with "foo" is already in your Gemfile.

Bundler and RubyGems have no CLI that edits a gemspec constraint, so this cannot be a definition change. replace_manifest.go already edits Gemfile source lines directly for Replace; a similar text-edit path for gemspec add_dependency/add_runtime_dependency version arguments would let Add/Update target the constraint that actually ships.

Related: cargo has cargo add foo@1.2.3 which edits Cargo.toml, and gomod has go get foo@v1.2.3 which edits go.mod; both target the published manifest. Bundler is the odd one out because Gemfile and gemspec are separate files with the constraints in the latter.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions