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.
A publishable gem declares its dependency constraints in the
.gemspec:Manager.Add(ctx, "foo", AddOptions{Version: "2.0"})for the bundler definition runsbundle add foo --version 2.0, which appends toGemfile. The published constraint in the gemspec is unchanged, and if the gem was already in the Gemfile via agemspecdirective,bundle addfails 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.goalready edits Gemfile source lines directly forReplace; a similar text-edit path for gemspecadd_dependency/add_runtime_dependencyversion arguments would letAdd/Updatetarget the constraint that actually ships.Related: cargo has
cargo add foo@1.2.3which editsCargo.toml, and gomod hasgo get foo@v1.2.3which editsgo.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.