Skip to content

Make DEFAULT_INSTALL_EXTENSION_IN_LIB to false#9240

Merged
hsbt merged 2 commits intomasterfrom
disable-to-install-extension-lib
Feb 13, 2026
Merged

Make DEFAULT_INSTALL_EXTENSION_IN_LIB to false#9240
hsbt merged 2 commits intomasterfrom
disable-to-install-extension-lib

Conversation

@hsbt
Copy link
Copy Markdown
Member

@hsbt hsbt commented Jan 9, 2026

What is your fix for the problem, implemented in this PR?

install_extension_in_lib leads to install C extension artifacts to under the lib directory.

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

Copilot AI review requested due to automatic review settings January 9, 2026 03:34
@hsbt hsbt changed the title Make DEFAULT_INSTALL_EXTENSION_IN_LIB false by default to stop instal… Make DEFAULT_INSTALL_EXTENSION_IN_LIB to false Jan 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 9, 2026

@hsbt I've opened a new pull request, #9241, to work on those changes. Once the pull request is ready, I'll request review from you.

@hsbt hsbt force-pushed the disable-to-install-extension-lib branch from 8eaf071 to bcc9e0d Compare January 26, 2026 06:51
hsbt and others added 2 commits February 13, 2026 09:07
…ialize

Co-authored-by: hsbt <12301+hsbt@users.noreply.github.com>
@hsbt hsbt force-pushed the disable-to-install-extension-lib branch from bcc9e0d to cf8c9ee Compare February 13, 2026 00:07
@hsbt hsbt enabled auto-merge February 13, 2026 00:07
@hsbt hsbt merged commit a8fb835 into master Feb 13, 2026
95 of 97 checks passed
@hsbt hsbt deleted the disable-to-install-extension-lib branch February 13, 2026 00:59
@rwstauner
Copy link
Copy Markdown
Contributor

As #8921 suggests, this causes a lot of gems to break at runtime (they install ok, but when loading the app the require fails).

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?
Was there any plan to contact gem maintainers?
Should we actually recommend configuring install_extension_in_lib: true for deployed installations (where installed gems aren't going to be shared) so that they don't need to wait for new releases of every native extension they use?

@hsbt
Copy link
Copy Markdown
Member Author

hsbt commented Feb 25, 2026

@rwstauner Thanks for your work.

Are we sure we want to go forward with this?

Yes, I have no plan to revert this now.

Was there any plan to contact gem maintainers?

I will publish upgrading guide same as https://blog.rubygems.org/2025/12/03/upgrade-to-rubygems-bundler-4.html

Should we actually recommend configuring install_extension_in_lib: true for deployed installations (where installed gems aren't going to be shared) so that they don't need to wait for new releases of every native extension they use?

I think this is necessary for projects that need to continue using gems that are unlikely to be updated, such as sassc.

@jhawthorn
Copy link
Copy Markdown
Member

While I agree we probably shouldn't install to lib (and I also don't like the default use of require_relative), this will break any native extension created using the default template in the last 6 years (everything between #4066 and #9156). That's a pretty extreme compatibility issue with no advance notice.

marcoroth added a commit to marcoroth/herb that referenced this pull request Mar 3, 2026
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>
jhawthorn added a commit to jhawthorn/ractor_safe that referenced this pull request Mar 6, 2026
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 added a commit to jhawthorn/json_escape that referenced this pull request Mar 6, 2026
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 added a commit to jhawthorn/rbdbg that referenced this pull request Mar 6, 2026
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 added a commit to jhawthorn/unsafe that referenced this pull request Mar 6, 2026
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.
@hsbt
Copy link
Copy Markdown
Member Author

hsbt commented Mar 12, 2026

@jhawthorn Initially, I wondered why the C extension was require_relative, but after reading #9240 (comment), I realized that we was using require_relative for a C extension in a template.

I'll also look into ways to restore settings and warn about this issue with rake build, etc. Thanks for your pointing out.

Thejus-Paul added a commit to gembakery/prebake that referenced this pull request Mar 31, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants