Closed fxn closed 4 months ago
Alrigth, I tracked it down to Bootsnap::ExplicitRequire.with_gems
: https://github.com/Shopify/bootsnap/commit/07bd09e06913ac172db0ba0d2a0c555f51a451d2
When calling require "msgpack"
the Rubygems require
patch essentially calls Gem.try_activate("msgpack")
that adds message pack's directories in the $LOAD_PATH
, so it can be required.
Then ExplicitRequire.with_gems
does a hack to try to speedup requiring depedencies. It saves the $LOAD_PATH
, then reduce it, require and restore the $LOAD_PATH
.
But this hack wasn't tested in bundler-less environment, so it never expected the call to require
to add entries in the $LOAD_PATH
, so when it restores it, the paths added by rubygems are lost and it causes the bug you showcase.
I can fix it by explicitly activating the gems passed to with_gems
before doing the $LOAD_PATH
trick.
:heart:
Disclaimer
I discovered this messing around, but do not personally need it fixed in practice.
Reporting just in case it is of the interest of the project.
I made sure the issue is in bootsnap
I did not investigate if the issue is in Bootsnap itself or perhaps in RubyGems.
Steps to reproduce
Minimal example, does not need a Gemfile, can be reproduced in an empty directory:
Expected behavior
We get a prompt back.
Actual behavior
While the gem
msgpack
is installed:Bootsnap initialization is not able to load it:
System configuration
Bootsnap version:
1.18.3
Ruby version:
3.3.0
RubyGems version:
3.5.15