1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib
David Rodríguez 4a417b08ae [rubygems/rubygems] Fix incorrect bundler version being required
In ruby 2.7.0, there's a slight change in bundler's default gemspec file
where the executable folder of the bundler gem is `libexec` instead of
`exe`. I made that change in https://github.com/ruby/ruby/pull/2380 to
try to simplify the integration of the `bundler` gem with upstream,
minimizing the number of changes that need to be made to the gemspec to
adapt to the structure of ruby-core.

That worked ok, expected for this issue. The new name of the folder
including the executable files uncovered a bug in rubygems, which is the
following:

* In order to be able to use newer versions of default gems, `rubygems`
ships with a customized `require` that has knowledge about which files
belong to which default gem. If one of these files is required,
`rubygems` will detect that and activate its gem mechanism to choose the
newest version of the corresponding default gem present in the system
(unless a different version has already been activated). It's this part
of the custom require:

ea3e6f194d/lib/rubygems/core_ext/kernel_require.rb (L77-L85)

* In order to do that, `rubygems` registers a map of default gems and
their files when it is first required:

ea3e6f194d/lib/rubygems.rb (L1247-L1276)

As explained in the method's header, two types of default gem
specifications are supported. One of the formats is the style used by
some ruby-core gemspec files, where paths inside the `spec.files` array
don't include the `spec.require_paths` part. So in this "old style", if
a gem ships with a `lib/bundler.rb` file, it will be registered in this
array as `spec.files = ["bundler.rb"]`, not as `spec.files =
["lib/bundler.rb"]`. The `Gem.register_default_spec` method "detects"
this style by making sure that none of the files in the `spec.files`
array start with any of the `spec.require_paths`.

* Since in ruby 2.7 the default specification file of the `bundler` gem
includes a `libexec/bundle` file, this check would no longer work
correctly, because even though the specification file is still "old
style", it has one registered file which starts with "lib", one of the
"require paths" of the gem.

* This means that the gem is incorrectly detected as "new style", but
since none of the paths start with "lib/", no files are actually
registered, so the gem is not being considered a default gem, and thus
the default version is always used with no possibility of being
"upgraded".

The fix of the problem is simple: check that no files start with `lib/`
(or any other require paths), instead of with "lib" which doesn't
exclude other potential "non requirable folder" starting with lib, like
in the `bundler` case.

https://github.com/rubygems/rubygems/commit/94df740c2b
2020-05-08 14:13:29 +09:00
..
benchmark Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
bundler [rubygems/rubygems] Properly look for man pages 2020-05-08 14:13:29 +09:00
cgi Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
csv
delegate Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
did_you_mean Sync did_you_mean 2019-12-24 18:41:55 -05:00
drb lib/drb/drb.rb: Use ruby2_keywords for keyword separation 2020-02-15 16:27:03 +09:00
forwardable
getoptlong Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
irb [ruby/irb] Suppress "method redefined" warning 2020-04-29 19:13:14 +09:00
logger Suppress security alerts 2020-02-28 21:05:08 -08:00
matrix Fix gemspec 2020-05-05 17:04:11 -04:00
net The current net-http is only works with Ruby 2.6+ 2020-04-08 15:59:55 +09:00
observer Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
open3 Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
optparse
ostruct [ruby/ostruct] Bump version 2019-12-22 21:48:54 -05:00
pstore Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
racc Fixed typos in racc 2020-04-27 15:28:06 +09:00
rdoc Support XDG_* (#2174) 2020-04-23 19:16:06 +09:00
reline [ruby/reline] Add URL reference of history-size 2020-04-29 19:13:14 +09:00
rinda
rubygems [rubygems/rubygems] Specify explicit separator not to be affected by $; 2020-05-08 14:13:29 +09:00
singleton Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
timeout Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
tracer
unicode_normalize
uri [ruby/uri] Check if DN exists 2020-05-05 23:29:39 +09:00
weakref [ruby/weakref] Update TODO on README 2020-04-08 18:33:00 +09:00
webrick webrick/ssl: More keyUsage for self-signed certs 2020-04-03 00:49:12 +09:00
yaml Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
.document Bundler is not documented in RDoc, but something different 2020-04-07 13:01:19 +09:00
abbrev.rb
base64.rb
benchmark.rb
bundler.rb
cgi.rb
csv.rb
debug.rb
delegate.rb Support obj.clone(freeze: true) for freezing clone 2020-03-22 09:30:07 -07:00
did_you_mean.rb
drb.rb
English.gemspec Update the version of published gemspec. 2020-04-08 14:21:14 +09:00
English.rb
erb.rb
fileutils.gemspec
fileutils.rb brace the fact that lchmod(2) can EOPNOTSUPP 2020-01-24 10:49:35 +09:00
find.rb
forwardable.rb
getoptlong.rb
ipaddr.gemspec Suppress security alerts 2020-02-28 21:05:08 -08:00
ipaddr.rb
irb.rb [DOC] get rid of parsing as TIDYLINK unintentionally 2020-04-07 13:59:38 +09:00
logger.rb
matrix.rb [ruby/matrix] Add Matrix#adjoint [#14] 2020-05-01 03:25:15 -04:00
mkmf.rb Added tooldir variable 2020-04-05 09:26:57 +09:00
mutex_m.gemspec
mutex_m.rb
observer.rb
open-uri.rb [DOC] get rid of parsing as TIDYLINK unintentionally 2020-04-07 13:59:38 +09:00
open3.rb
optionparser.rb
optparse.rb
ostruct.rb Fix OpenStructDocumentation 2020-01-05 14:35:14 +09:00
pp.rb Fix pp when passed a empty ruby2_keywords-flagged hash as array element 2020-01-22 10:27:02 -08:00
prettyprint.rb Fix articles. 2020-04-11 02:32:23 +09:00
prime.gemspec Update the latest gemspec of prime. 2020-04-08 14:33:22 +09:00
prime.rb Improve docs for Prime.{prime_division,int_from_prime_division} (#8) 2020-03-06 20:55:22 +09:00
pstore.rb
racc.rb
rdoc.rb Skip the initialization of XDG_DATA_HOME with Permission denied 2020-04-23 21:11:21 +09:00
readline.gemspec [ruby/readline] Version 0.0.2 2019-12-25 10:57:44 +09:00
readline.rb
reline.rb [ruby/reline] Suppress error when check ambiguous char width in LANG=C 2020-03-26 17:41:21 +09:00
resolv-replace.rb
resolv.rb
rubygems.rb [rubygems/rubygems] Fix incorrect bundler version being required 2020-05-08 14:13:29 +09:00
securerandom.rb
set.rb Support obj.clone(freeze: true) for freezing clone 2020-03-22 09:30:07 -07:00
shellwords.rb
singleton.rb
tempfile.gemspec The current tempfile.rb is only works with Ruby 2.5+ 2020-04-08 15:20:44 +09:00
tempfile.rb
time.rb
timeout.rb
tmpdir.gemspec Add workaround for test-bundler failure 2020-03-12 19:17:08 +09:00
tmpdir.rb Isolate the PRNG for tmpdir/tempfile 2020-01-29 10:14:15 +09:00
tracer.rb
tsort.rb
un.rb DocumentRoot is optional 2020-01-21 18:13:54 +09:00
uri.rb [ruby/uri] Remove RCS keywords 2020-03-26 18:06:14 +09:00
weakref.rb
webrick.rb
yaml.rb