From c31ab533e8762b339e9b427fb1d12d7e8143e455 Mon Sep 17 00:00:00 2001 From: Jacob Steves Date: Tue, 14 Dec 2021 09:51:32 -0500 Subject: [PATCH 1/2] support installing proper version of javy on mac universal ruby distribution --- ext/javy/javy.rb | 15 +++++++-------- test/ext/javy/javy_test.rb | 15 +++++++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ext/javy/javy.rb b/ext/javy/javy.rb index 4d01281b85..f74c84b12b 100644 --- a/ext/javy/javy.rb +++ b/ext/javy/javy.rb @@ -1,4 +1,3 @@ -require "rbconfig" require "open-uri" require "zlib" require "open3" @@ -162,9 +161,9 @@ def validate_sha!(source) end end - Platform = Struct.new(:ruby_config) do - def initialize(ruby_config = RbConfig::CONFIG) - super(ruby_config) + Platform = Struct.new(:ruby_platform) do + def initialize(ruby_platform = RUBY_PLATFORM) + super(ruby_platform) end def to_s @@ -172,7 +171,7 @@ def to_s end def os - case ruby_config.fetch("host_os") + case ruby_platform when /linux/ "linux" when /darwin/ @@ -183,10 +182,10 @@ def os end def cpu - case ruby_config.fetch("host_cpu") - when "x64", "x86_64" + case ruby_platform + when /x64/, /x86_64/ "x86_64" - when "arm" + when /arm/ "arm" else raise InstallationError.cpu_unsupported diff --git a/test/ext/javy/javy_test.rb b/test/ext/javy/javy_test.rb index 04df351eb0..816233bf57 100644 --- a/test/ext/javy/javy_test.rb +++ b/test/ext/javy/javy_test.rb @@ -154,6 +154,12 @@ def test_recognizes_mac_os_arm assert_equal "javy", platform.format_executable_path("javy") end + def test_recognizes_underlying_cpu_in_universal_distributions + platform = Javy::Platform.new(PlatformHelper.macos_universal_config) + assert_equal "arm-macos", platform.to_s + assert_equal "javy", platform.format_executable_path("javy") + end + def test_recognizes_windows platform = Javy::Platform.new(PlatformHelper.windows_config) assert_equal "x86_64-windows", platform.to_s @@ -220,6 +226,10 @@ def self.macos_arm_config ruby_config(os: "darwin20.3.0", cpu: "arm") end + def self.macos_universal_config + ruby_config(os: "darwin20.3.0", cpu: "universal.arm64") + end + def self.windows_config ruby_config(os: "mingw32", cpu: "x64") end @@ -229,10 +239,7 @@ def self.windows_32_bit_config end def self.ruby_config(os:, cpu:) - { - "host_os" => os, - "host_cpu" => cpu, - } + "#{cpu}-#{os}" end end end From 66d22779651be4829db8fd9374c1a1de5f98b13b Mon Sep 17 00:00:00 2001 From: Jacob Steves Date: Tue, 14 Dec 2021 13:02:58 -0500 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 963f69918b..9d5c0e43c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](https://keepachangelog.com/en/1.0.0/) specification. + +## [Unreleased] +### Fixed +* [#1853](https://github.com/Shopify/shopify-cli/pull/1853): Fix javy installation failures from MacOS universal ruby installations ## Version 2.7.3 ### Added * [#1826](https://github.com/Shopify/shopify-cli/pull/1826): Support using `script.config.yml` file for script configuration