| Age | Commit message (Collapse) | Author |
|
- Fix https://github.com/ruby/rubygems/issues/9238
- ### Problem
This is an issue that bites gem maintainers from time to time, with
the most recent one in https://github.com/minitest/minitest/issues/1040#issuecomment-3679370619
The issue is summarized as follow:
1) A gem "X" has a feature in "lib/feature.rb"
2) Maintainer wants to extract this feature into its own gem "Y"
3) Maintainer cut a release of X without that new feature.
4) Users install the new version of X and also install the new
gem "Y" since the feature is now extracted.
5) When a call to "require 'feature'" is encountered, RG will
fail to load the right gem, resulting in a `LoadError`.
### Details
Now that we have two gems (old version of X and new gem Y) with
the same path, RubyGems will detect that `feature.rb` can be loaded
from the old version of X, but if the new version of X had already
been loaded, then RubyGems will raise due to versions conflicting.
```ruby
require 'x' # Loads the new version of X without the feature which was extracted.
require 'feature' # Rubygems see that the old version of X include that file and tries to activate the spec.
```
### Solution
I propose that RubyGems fallback to a spec that's not yet loaded.
We try to find a spec by its path and filter it out in case a spec
with the same name has already been loaded.
Its worth to note that RubyGems already has a
`find_inactive_by_path` but we can't use it. This method only checks
if the spec object is active and doesn't look if other spec with the
same name have been loaded. The new method we are introducing
verifies this.
https://github.com/ruby/rubygems/commit/f298e2c68e
|
|
https://github.com/ruby/rubygems/commit/43371085f4
|
|
It seems like we were trying to deprecate passing `nil` to
Gem::Version.new. This breaks existing code, and I don't think there is
a good reason to deprecate this usage.
I believe what we want to prevent is the following code:
```ruby
Gem::Specification.new do |spec|
spec.version = nil
# suddenly the spec version is 0!
p spec.version
end
```
This commit allows people to manually construct `Gem::Version.new(nil)`,
but when someone assigns `nil` as the Gem specification version, it sets
the spec version to `nil` (making the specification invalid). People
who manually construct `Gem::Version` objects and use nil should be
allowed to do it, and `Gem::Version.new(nil) == Gem::Version.new("0")`,
but people who assign `nil` in a gemspec will get an invalid gemspec.
I think deprecation started
[here](https://github.com/ruby/rubygems/pull/2203) but there doesn't
seem to be a reason to do it.
Fixes https://github.com/ruby/rubygems/pull/9052
https://github.com/ruby/rubygems/commit/ded5e909c2
|
|
and has_rdoc?
https://github.com/ruby/rubygems/commit/b043538576
|
|
https://github.com/ruby/rubygems/commit/94d4e633d1
|
|
validate_dependencies and validate_permissions
https://github.com/ruby/rubygems/commit/fbf38fc190
|
|
https://github.com/ruby/rubygems/commit/84ceaff1b7
|
|
I don't think these methods are hotspots, and since gem specifications
are sometimes serialized to yaml / marshal, I think we should remove as
many instance variables as possible
https://github.com/rubygems/rubygems/commit/40490d918b
|
|
https://github.com/rubygems/rubygems/commit/b58829a868
|
|
https://github.com/rubygems/rubygems/commit/0e40e7d938
|
|
https://github.com/rubygems/rubygems/commit/792117980b
|
|
dependency
If you force uninstall a dependency but leave other gems depending on
it, those gems will fail to be activated.
In that case, RubyGems prints a rather complicated error:
```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1413:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/dependency.rb:303:in 'Gem::Dependency#to_specs': Could not find 'activesupport' (= 8.0.1) - did find: [activesupport-7.1.3,activesupport-7.0.8.7] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' , execute `gem env` for more information
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1411:in 'block in Gem::Specification#activate_dependencies'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```
With this commit, the error becomes a bit simpler to parse:
```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1421:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Array#each'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Gem::Specification#activate_dependencies'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1389:in 'Gem::Specification#activate'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```
And also, we reduce exception based control flow in our code.
https://github.com/rubygems/rubygems/commit/7e48c49f2d
|
|
https://github.com/rubygems/rubygems/commit/12f3e78c95
|
|
Notes:
Merged: https://github.com/ruby/ruby/pull/12444
|
|
`Gem::Specification.reset` on benign cases
If `Gem::Specification.reset` is used, but there are still unresolved
dependencies, RubyGems prints a warning. There are though, certain cases
where the situation will not cause any issues.
One such case is when the unresolved dependency does not restrict any
versions (>= 0) and there's a default gem matching it.
In this situation, it doesn't matter if Gem paths change, because
default gems are still activatable, so the dependency will be properly
activated if ever needed.
https://github.com/rubygems/rubygems/commit/e5f8a3068e
|
|
https://github.com/rubygems/rubygems/commit/d8d68cc00e
|
|
sometimes
If a gem package is built from a specification whose platform has been
modified, it will include metadata using the old platform.
This change should fix the problem by making sure `original_platform` is
always properly set.
https://github.com/rubygems/rubygems/commit/ecd5cd4547
|
|
https://github.com/rubygems/rubygems/commit/fe9999f2cf
|
|
If old Bundler versions that unconditionally try to remove this method
are run with RubyGems versions _without_ this method, Bundler crashes
because it tries to remove a method that does not exist.
We need to wait until RubyGems cannot install any Bundler versions that
unconditionally remove this method.
https://github.com/rubygems/rubygems/commit/98804d261d
|
|
for some reason
https://github.com/rubygems/rubygems/commit/f8f589b1b8
|
|
This could happen when a regular gem shadows a default gem.
https://github.com/rubygems/rubygems/commit/9ef70dd1f7
|
|
`Gem::Specification.reset` warning
https://github.com/rubygems/rubygems/commit/e6e3db821f
|
|
It has been supported since RubyGems 2.2.0 via https://github.com/rubygems/rubygems/commit/4525e45a4d45
Signed-off-by: Samuel Giddins <segiddins@segiddins.me>
https://github.com/rubygems/rubygems/commit/bf39c583e8
|
|
https://github.com/rubygems/rubygems/commit/058b29fe98
|
|
https://github.com/rubygems/rubygems/commit/7cf2fdcfa1
|
|
correctly unmarshalled
https://github.com/rubygems/rubygems/commit/d6ba7ef79f
|
|
It was not properly being detected as an Array attribute, and thus not
properly validated.
Fixing this allows us to remove a strange `rescue` clause in Bundler.
https://github.com/rubygems/rubygems/commit/4121a32408
|
|
Also limit caller ranges
https://github.com/rubygems/rubygems/commit/a274b1af78
|
|
https://github.com/rubygems/rubygems/commit/0236cb6191
|
|
This method validates only what is required for resolution, skipping any
irrelevant metadata validation. This will be used by Bundler instead of
doing a full validation, allowing gem authors to use `bundle` commands
immediately in newly created gems without first having to fix invalid
metafata fields in the default gemspec.
https://github.com/rubygems/rubygems/commit/da7704cfc0
|
|
https://github.com/rubygems/rubygems/commit/7e6e7ccc58
|
|
https://github.com/rubygems/rubygems/commit/8dbe1dbdc7
Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
|
|
https://github.com/rubygems/rubygems/commit/6b70e9043d
|
|
`--destdir` is given
This was only working for gems also installed in the default gem home.
https://github.com/rubygems/rubygems/commit/47df02dbd9
|
|
So that it can also be delegated to `Gem::SpecificationRecord`.
https://github.com/rubygems/rubygems/commit/1407807a99
|
|
When `gem uninstall <gem> --install-dir <dir>` is run, if the version
removed had a plugin, and that same version happened to also be
installed globally, then the plugin stub would fail to be removed.
https://github.com/rubygems/rubygems/commit/4e2fa0be77
|
|
This class handles all logic to handle the list of specifications, given
a set of GEM_PATH directories. Makes `Gem::Specification` has less
responsibilities and will help with fixing some bugs next.
https://github.com/rubygems/rubygems/commit/df280dbbed
|
|
Other analog methods are documented, so document this one too.
https://github.com/rubygems/rubygems/commit/76da34d44d
|
|
I don't think this method is any worse than others, let's only document
what it does.
https://github.com/rubygems/rubygems/commit/dec722187f
|
|
https://github.com/rubygems/rubygems/commit/7b71965a70
|
|
This gets in the middle if we ever start allowing to build as if using a
different RubyGems version than the one being run.
This could be useful to make `gem rebuild` a little more usable, and
it's already done by Bundler specs which already make this method a noop
when they need this.
I'm not sure forcefully setting this, even if user explicitly specified
something else is helpful.
Since this could potentially prevent gems explicitly setting a constant
RubyGems version from building, I changed the error of incorrect
RubyGems version from a hard error to a warning, since it will start
happening in those cases if we stop overwriting the version.
https://github.com/rubygems/rubygems/commit/45676af80d
|
|
Nil-value keys in a mapping end with a space or not depending on
libyaml versions, and result metadata are different per platforms.
This commit makes to skip such keys to make metadata reproducible
accross platforms.
https://github.com/rubygems/rubygems/commit/74b4db8d30
|
|
https://github.com/rubygems/rubygems/commit/bcbe6f7b7a
|
|
requirements
to avoid accidentally mutating the original's state when doing:
```ruby
spec2 = spec.dup
spec2.required_rubygems_version.concat([">= 3.3.22"])
```
see https://github.com/rake-compiler/rake-compiler/pull/236 for a
real-world use case that would be made simpler with this behavior.
https://github.com/rubygems/rubygems/commit/c1d52389f0
|
|
These were introduced 13 years ago, in a documentation update. Perhaps we can let the TODOs go, without taking any action?
https://github.com/rubygems/rubygems/commit/fb23fa84f9
|
|
https://github.com/rubygems/rubygems/commit/4691b959ad
|
|
I think we can safely assume these days that all RubyGems and Bundler
versions that will ever bundle a new gem created in 2023 support
prereleases.
So this non transparent requirement is not necessary.
In my opinion, it should be the gem author to explicitly add this
constraint, not RubyGems.
https://github.com/rubygems/rubygems/commit/b165e6d725
|
|
https://github.com/rubygems/rubygems/commit/bb66253f2c
|
|
https://github.com/rubygems/rubygems/commit/56ce2a6445
|
|
https://github.com/rubygems/rubygems/commit/70243b1d72
|