Skip to content

build: build with baseruby that is compiled from the same source - #15

Merged
kateinoigakukun merged 1 commit into
mainfrom
katei/fix-gem-default-dir
May 11, 2022
Merged

kateinoigakukun merged 1 commit into
mainfrom
katei/fix-gem-default-dir

Conversation

@kateinoigakukun

Copy link
Copy Markdown
Member

The system installed Ruby (especially Debian) can override
Gem.default_dir to lookup gems installed by the OS package managers.
And rbinstall.rb respects Gem.default_dir to select install
directory of gems under DESTDIR. So it installs gems in
DESTDIR/var/lib/gems/3.2.0+1 where the Debian's operating_system.rb
specifies.
However, Gem.default_dir is not overridden at runtime on Wasm, so it
lookups DESTDIR/usr/local/lib/ruby/gems/3.2.0+1 instead. The mismatch
of default_dir between install-time and runtime causes the failure of
gem lookup.
To fix this mismatch, stop using system packaged ruby to avoid loading
operating_system.rb, and use self-built ruby, which doesn't patch
Gem.default_dir.
This change also makes our build compatible with cross-compilation
prerequisite:
https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#prerequisite

The system installed Ruby (especially Debian) can override
`Gem.default_dir` to lookup gems installed by the OS package managers.
And `rbinstall.rb` respects `Gem.default_dir` to select install
directory of gems under `DESTDIR`. So it installs gems in
`DESTDIR/var/lib/gems/3.2.0+1` where the Debian's `operating_system.rb`
specifies.
However, `Gem.default_dir` is not overridden at runtime on Wasm, so it
lookups `DESTDIR/usr/local/lib/ruby/gems/3.2.0+1` instead. The mismatch
of `default_dir` between install-time and runtime causes the failure of
gem lookup.
To fix this mismatch, stop using system packaged ruby to avoid loading
`operating_system.rb`, and use self-built ruby, which doesn't patch
`Gem.default_dir`.
This change also makes our build compatible with cross-compilation
prerequisite:
https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#prerequisite
@kateinoigakukun
kateinoigakukun force-pushed the katei/fix-gem-default-dir branch from 7309042 to 1e1f70c Compare May 11, 2022 05:51
@kateinoigakukun
kateinoigakukun merged commit 8788d54 into main May 11, 2022
@kateinoigakukun
kateinoigakukun deleted the katei/fix-gem-default-dir branch May 11, 2022 06:31
@c4lliope c4lliope mentioned this pull request May 12, 2022
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.

1 participant