This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
[scripts] use RUBY_PLATFORM instead of RbConfig to check platform details for Javy installation #1853
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.
WHY are these changes introduced?
Mac machines come preinstalled with a universal distribution of Ruby created by Apple that includes both arm64 and x86 binaries, and will use the appropriate one depending on the cpu of the machine. There is a bug (or a confusing feature?) in the distribution with the use of
RbConfig
. No matter what CPU you're on (intel or M1) theRbConfig
sets thehost_cpu
field tox86
. The current approach to installing Javy checks this variable and downloads the appropriate binary, but if you're on an M1 machine, that means we download the binary for Intel machines. When you install a new version of ruby with chruby/vrm/brew, then this problem disappears. However, Javy should work out of the box.WHAT is this pull request doing?
Instead of using
RbConfig::CONFIG
, useRUBY_PLATFORM
constant. This constant reports the host machine cpu, even when using a universal distribution. For arm it reportsuniversal.arm64-darwin<version>
and for x86 it reportsuniversal.x86_64-darwin<version>
. I am currently downloading linux and windows VMs to verify that it works there, but there should be no problems as there is code out there that does the same thing.How to test your changes?
Ideally, you would test this on M1 and Intel machines. I have tested on both myself, though.
RUBY_PLATFORM
. It should give you the details on if you're using a universal distribution or a platform specific one.which ruby
in the shell./usr/bin/ruby
indicates that you're using the default system ruby install.chruby_use 2.7.1
./usr/bin/ruby
.shopify-cli
directory and rundev up
. This will install ruby 2.7.5. To use this ruby version, create atemp/
folder in the repo and create your scripts there.npm run prebuild
to compile the TS into JSshopify script javy -i build/index.js -o build/index.wasm
build/index.wasm
My 🎩
Using a universal installation on M1
Using an arm installation on M1
Update checklist