diff options
| author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2024-11-05 17:55:41 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-11-07 10:03:54 +0000 |
| commit | ffcfaf4ce4eba4975f6ef79bf4b6c898180107f2 (patch) | |
| tree | f12945afd32234b5fe20aa0db9fcfa771fa50cd7 /lib | |
| parent | df3395f2e301e7739dda5b7455e8c6b1c25b334d (diff) | |
[rubygems/rubygems] Undeprecate Gemfiles without a global source
After having a second look at this deprecation, the explanation that
we're giving does not make a lot of sense. When working only with local
gems, Bundler will indeed generate a different lockfile depending on
the latest installed version of each gem is at `bundle install` time.
That's the same situation that happens with remote sources: Bundler will
generate a different lockfile depending on the latest version of each
gem available remotely.
So, I don't think "a consistent lockfile not getting generated" is a
good motivation for deprecating this.
Also, this deprecation brings additional challenges, since for example,
it should arguably not get printed when using `bundle install --local`?
The original problem when this deprecation was introduced was an
incorrect message about a missing gem having been yanked.
So, I think a better solution is to, as long as we give proper error
messages when things go wrong, let users do what's best for them and
undo the deprecation.
https://github.com/rubygems/rubygems/commit/17499cb83f
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bundler/definition.rb | 18 | ||||
| -rw-r--r-- | lib/bundler/dsl.rb | 13 |
2 files changed, 15 insertions, 16 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 9ce38209d6..84b7236a1f 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -608,10 +608,20 @@ module Bundler missing_specs.each do |s| locked_gem = @locked_specs[s.name].last next if locked_gem.nil? || locked_gem.version != s.version || sources.local_mode? - raise GemNotFound, "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \ - "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \ - "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \ - "removed in order to install." + + message = if sources.implicit_global_source? + "Because your Gemfile specifies no global remote source, your bundle is locked to " \ + "#{locked_gem} from #{locked_gem.source}. However, #{locked_gem} is not installed. You'll " \ + "need to either add a global remote source to your Gemfile or make sure #{locked_gem} is " \ + "available locally before rerunning Bundler." + else + "Your bundle is locked to #{locked_gem} from #{locked_gem.source}, but that version can " \ + "no longer be found in that source. That means the author of #{locked_gem} has removed it. " \ + "You'll need to update your bundle to a version other than #{locked_gem} that hasn't been " \ + "removed in order to install." + end + + raise GemNotFound, message end missing_specs_list = missing_specs.group_by(&:source).map do |source, missing_specs_for_source| diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index df904f074a..a7b7df84a6 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -503,18 +503,7 @@ module Bundler end def check_rubygems_source_safety - if @sources.implicit_global_source? - implicit_global_source_warning - elsif @sources.aggregate_global_source? - multiple_global_source_warning - end - end - - def implicit_global_source_warning - Bundler::SharedHelpers.major_deprecation 2, "This Gemfile does not include an explicit global source. " \ - "Not using an explicit global source may result in a different lockfile being generated depending on " \ - "the gems you have installed locally before bundler is run. " \ - "Instead, define a global source in your Gemfile like this: source \"https://rubygems.org\"." + multiple_global_source_warning if @sources.aggregate_global_source? end def multiple_global_source_warning |
