Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug #21453] Override files in gemspec file before eval #13724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025

Conversation

nobu
Copy link
Member

@nobu nobu commented Jun 27, 2025

executables are often extracted from the files in gemspec files.

`executables` are often extracted from the `files` in gemspec files.
@nobu nobu force-pushed the files-in-gemspec branch from 3d39fac to 7ce3392 Compare June 27, 2025 06:17
@matzbot matzbot merged commit 7ce3392 into ruby:master Jun 27, 2025
92 of 94 checks passed
@nobu nobu deleted the files-in-gemspec branch June 27, 2025 07:30
@MSP-Greg
Copy link
Contributor

@nobu

This caused some failures in ruby-loco. The failures were with rubygems' tests that are skipped when run in master from 'build'. ruby-loco runs tests from 'install'.

I think a proper json gemspec shows:

s.files = [
  "README.md".freeze,
  "json.rb".freeze,
  "json/add/bigdecimal.rb".freeze,
  "json/add/complex.rb".freeze,
  "json/add/core.rb".freeze,
  "json/add/date.rb".freeze,
  "json/add/date_time.rb".freeze,
  "json/add/exception.rb".freeze,
  "json/add/ostruct.rb".freeze,
  "json/add/range.rb".freeze,
  "json/add/rational.rb".freeze,
  "json/add/regexp.rb".freeze,
  "json/add/set.rb".freeze,
  "json/add/struct.rb".freeze,
  "json/add/symbol.rb".freeze,
  "json/add/time.rb".freeze,
  "json/common.rb".freeze,
  "json/ext.rb".freeze,
  "json/ext/generator/state.rb".freeze,
  "json/generic_object.rb".freeze,
  "json/version.rb".freeze]

After this PR/commit, the json data is:

s.files = [
  "BSDL".freeze,
  "CHANGES.md".freeze,
  "COPYING".freeze,
  "LEGAL".freeze,
  "README.md".freeze,
  "ext/json/extconf.h".freeze,
  "ext/json/generator/extconf.h".freeze,
  "ext/json/parser/extconf.h".freeze,
  "json.gemspec".freeze]

A one-liner I used to check was:

ruby -rjson -e "puts Gem.loaded_specs.keys.sort; puts JSON::VERSION; puts Gem.find_default_spec('json')"

@MSP-Greg
Copy link
Contributor

@nobu

Thanks for working on this. Locally, I built the commit before this (8bba087), and ruby-loco CI passed. I then built with this locally, and the two tests failed. I also mentioned them in https://bugs.ruby-lang.org/issues/21458.

─────────────────────────────────────────────────────── 2 Failures
                                                          /ruby/test/rubygems/test_require.rb

TestGemRequire#test_realworld_default_gem                 Line: 471  
Expected "" to not be empty.

TestGemRequire#test_realworld_upgraded_default_gem        Line: 492  
<"999.99.9"> expected but was
<"/ruby/tmp/test_rubygems_20250628-9100-yib0la/test_realworld_upgraded_default_gem.rb:3:in '<main>': undefined method 'version' for nil (NoMethodError)">.

@ntkme
Copy link
Contributor

ntkme commented Jun 30, 2025

I opened https://bugs.ruby-lang.org/issues/21462, and later I found out about this. There are at least three gems directly affected by this:

  • json-2.12.2.gemspec
  • openssl-3.3.0.gemspec
  • optparse-0.7.0.dev.2.gemspec

The fundamental problem here is that all default gems install in a single shared directory. When a default gemspec contains a glob e.g. Dir['lib/**/*.rb'] it will match all files from other default gems installed in the same dir thus causing this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants