Make DEFAULT_INSTALL_EXTENSION_IN_LIB to false#9240
Conversation
false
There was a problem hiding this comment.
Pull request overview
This pull request changes the default value of DEFAULT_INSTALL_EXTENSION_IN_LIB from true to false in RubyGems. This change stops installing C extension artifacts to the lib directory by default, making it easier to share gems across different Ruby versions. The change was planned for RubyGems 4.0 (as indicated by the removed TODO comment) and is now being implemented in version 4.1.0.dev.
Key changes:
- Changes default behavior for C extension installation location
- Removes the TODO comment that indicated this change should happen in RubyGems 4.0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| DEFAULT_IPV4_FALLBACK_ENABLED = false | ||
| # TODO: Use false as default value for this option in RubyGems 4.0 | ||
| DEFAULT_INSTALL_EXTENSION_IN_LIB = true | ||
| DEFAULT_INSTALL_EXTENSION_IN_LIB = false |
There was a problem hiding this comment.
The test in test_initialize doesn't verify the default value of install_extension_in_lib when no configuration is provided. Consider adding an assertion like assert_equal false, @cfg.install_extension_in_lib in the first part of the test_initialize method (around line 45) to explicitly test that the new default value is false when no config file setting overrides it.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
8eaf071 to
bcc9e0d
Compare
…ling extensions into lib directory
…ialize Co-authored-by: hsbt <12301+hsbt@users.noreply.github.com>
bcc9e0d to
cf8c9ee
Compare
|
As #8921 suggests, this causes a lot of gems to break at runtime (they install ok, but when loading the app the We've patched several gems already after finding issues in CI, but there are many more that will need it:
Are we sure we want to go forward with this? |
|
@rwstauner Thanks for your work.
Yes, I have no plan to revert this now.
I will publish upgrading guide same as https://blog.rubygems.org/2025/12/03/upgrade-to-rubygems-bundler-4.html
I think this is necessary for projects that need to continue using gems that are unlikely to be updated, such as |
|
While I agree we probably shouldn't install to lib (and I also don't like the default use of |
This pull request changes the native extension loading from `require_relative` to `require` to ensure compatibility with the latest RubyGems, which no longer installs native extensions into the gem's `lib/` directory by default. See ruby/rubygems#9240. Using `require` resolves the extension through `$LOAD_PATH`, which RubyGems populates with both the `lib/` and extension directories, so this works on both old and new versions of RubyGems. Resolves #1244 Co-Authored-By: Daniel Colson <composerinteralia@github.com>
RubyGems is changing `install_extension_in_lib` to default to false (ruby/rubygems#9240), meaning native extensions will no longer be installed into `lib/`. `require_relative` won't be able to find the shared object, but `require` will since RubyGems adds the extension directory to the load path.
RubyGems is changing `install_extension_in_lib` to default to false (ruby/rubygems#9240), meaning native extensions will no longer be installed into `lib/`. `require_relative` won't be able to find the shared object, but `require` will since RubyGems adds the extension directory to the load path.
RubyGems is changing `install_extension_in_lib` to default to false (ruby/rubygems#9240), meaning native extensions will no longer be installed into `lib/`. `require_relative` won't be able to find the shared object, but `require` will since RubyGems adds the extension directory to the load path.
RubyGems is changing `install_extension_in_lib` to default to false (ruby/rubygems#9240), meaning native extensions will no longer be installed into `lib/`. `require_relative` won't be able to find the shared object, but `require` will since RubyGems adds the extension directory to the load path.
|
@jhawthorn Initially, I wondered why the C extension was I'll also look into ways to restore settings and warn about this issue with |
…ut bug RubyGems 4 stopped copying .so files into lib/ (ruby/rubygems#9240), and Bundler 2.5.x doesn't properly resolve the new extension directory layout, causing LoadError for native gems like bigdecimal. Document the workaround (upgrade Bundler + bust CI cache) and note the Bundler version requirement for Ruby 4.0 users.
What is your fix for the problem, implemented in this PR?
install_extension_in_libleads to install C extension artifacts to under thelibdirectory.This makes to hard to share gems across different version of Ruby. We should stop this in the future.
see also:
Make sure the following tasks are checked