Re-enable npm run test for renamed head-wasip2 package by fixing Bundler standalone compatibility#622
Merged
kateinoigakukun merged 2 commits intoruby:mainfrom Mar 8, 2026
Merged
Conversation
Renames the `FIXME_SKIP_test` script to `test` in `package.json`.
lib/ruby_wasm/packager/core.rb
Outdated
|
|
||
| # Bundler standalone setup.rb assumes that once `Gem` is defined, | ||
| # Gem.ruby_api_version and Gem.extension_api_version are also available. | ||
| # In ruby-head packaging this assumption can fail (Gem exists, but these |
Member
There was a problem hiding this comment.
Have they removed those APIs but just didn't update standalone mode code to reflect that, right? Ij that case, shouldn't we fix the bundler side instead?
Contributor
Author
There was a problem hiding this comment.
That makes sense. I'll proceed with the investigation.
kateinoigakukun
approved these changes
Mar 8, 2026
Member
kateinoigakukun
left a comment
There was a problem hiding this comment.
Makes sense to me! Thanks 🙏
As a follow-up, it might be better to fix Bundler's standalone code generator to detect the missing methods more granularly https://github.com/ruby/rubygems/blob/884d80fd158fead18bb4f021796a2af062a45ac9/bundler/lib/bundler/installer/standalone.rb#L76
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
2nd Challenge
Summary
This PR keeps
npm run testenabled for thehead-wasip2package flow by explicitly loading RubyGemsbefore Bundler standalone setup when the runtime is still in a partial
Gemstate.Root Cause
This was reproduced locally against the failing Ruby revision:
7d4983803887a45c311ab954de4527333b976500logs: https://github.com/ruby/ruby.wasm/actions/runs/22755141423/job/65997955482#step:16:146
At
rubyInitreturn time in that build, the runtime state was:Gemis definedGem.ruby_api_versionis missingGem.extension_api_versionis missingrubygems.rbis not loaded$LOAD_PATHdoes not yet include the main stdlib directories needed for RubyGemsRbConfig.rubyis stillnilBundler standalone setup assumes that
defined?(Gem)is enough to use RubyGems API helpers. In this runtime state,that assumption is false, so loading
/bundle/bundler/setup.rbfails before tests start.Fix
Before requiring
/bundle/bundler/setup.rb, load RubyGems explicitly when:Gemis already defined, andGem.ruby_api_versionis still missingThis keeps the workaround scoped to the Bundler standalone path used by the component-model package.
Why This Fix
This issue appears to depend on a specific Ruby revision and ruby.wasm startup state, not on Bundler standalone in
Given that:
I think, this fix is better.
1st Challenge
## SummaryThis PR re-enables
npm run testfor the renamedhead-wasip2npm package flow by fixing a Bundler standalone compatibility issue in the packagedruby- headruntime.Previously, the check step was effectively not running as intended after the rename. Once re-enabled, it failed during VM boot because generated
/bundle/ bundler/setup.rbexpected RubyGems API-version helpers that may be missing in this runtime combination.Goal
Ensure the renamed
head-wasip2package pipeline can runnpm run testin CI without being skipped, and pass the boot phase reliably.Root Cause
bundle install --standalonegeneratesbundle/.../bundler/setup.rbthat assumes:Gem.ruby_api_versionGem.extension_api_versionare available.
In
ruby-headpackaging/runtime combinations used by this workflow, either method can be missing, causingNoMethodErrorbefore tests execute.What Changed
1) Patch generated Bundler standalone setup after packaging
In
RubyWasm::Packager::Core::DynamicLinking#_build_gem_exts, after standalone bundle generation, we now call:patch_bundler_standalone_setup(local_path)This injects a compatibility shim into generated
bundler/setup.rbthat defines missing RubyGems API-version methods only when absent.2) Preserve Bundler path semantics
Instead of replacing
Gem.*_api_versionexpressions inline, this PR injects method shims so Bundler’s original extension/load-path logic remains intact(including shared/static behavior).
This avoids regressions like failing to resolve
js.so.3) Update type signatures
Added RBS declaration for the new private helper method.
Another solution
Modifying
bundler install --standalonemight be smarter.