Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Fix the Homebrew template #2047

Merged
merged 2 commits into from
Feb 14, 2022
Merged

Fix the Homebrew template #2047

merged 2 commits into from
Feb 14, 2022

Conversation

pepicrft
Copy link
Contributor

WHY are these changes introduced?

The changes in this PR broke the installation through Homebrew because the def ruby_bin method is trying to get the path to the Ruby binary from the wrong formula. I've updated it to read it from the ruby@3.0 and taken the opportunity to improve installation errors.

WHAT is this pull request doing?

Fix the template that we use to generate the formula at release time.

How to test your changes?

  1. Add the changes to /opt/homebrew/Library/Taps/shopify/homebrew-shopify/shopify-cli.rb.
  2. Uninstall the CLI with brew uninstall shopify-cli.
  3. Run brew install shopify-cli.

Update checklist

  • I've added a CHANGELOG entry for this PR (if the change is public-facing)
  • I've considered possible cross-platform impacts (Mac, Linux, Windows).
  • I've left the version number as is (we'll handle incrementing this when releasing).
  • I've included any post-release steps in the section above.

@pepicrft pepicrft requested review from amcaplan, gonzaloriestra and a team February 11, 2022 15:29
@pepicrft pepicrft self-assigned this Feb 11, 2022
@binarymonkey84
Copy link

Is it possible to add a Github check for brew install being successful prior to releases?

I just went to install shopify-cli on a new Macbook Pro but am unable to, so I can't work on my project.

Is there any way to install an older version or something to get around this issue until a fix is pushed?

@gonzaloriestra
Copy link
Contributor

@binarymonkey84 we should definitely improve our CI, thanks.

As a workaround while we release this, you can always install it via RubyGems: https://shopify.dev/apps/tools/cli/installation#install-shopify-cli

@binarymonkey84
Copy link

binarymonkey84 commented Feb 14, 2022

Thanks for your reply!

Yeah, I tried the Ruby Gems approach but this did not work on macOS. I get a permission denied error which according to a few other sources is what happens "out of the box" with macOS when trying to install a gem from Terminal.

So unfortunately I can't run the gem command listed on the Shopify dev docs - is there some other step by need to take before I do this?

And won't installing the CLI this way conflict with homebrew once that is working?

@gonzaloriestra
Copy link
Contributor

Do you have an M1? You can try applying this change to /opt/homebrew/Library/Taps/shopify/homebrew-shopify/shopify-cli.rb.

system("#{ruby_bin}/gem", "fetch", "shopify-cli", "--version", gem_version)
_, err, status = Open3.capture3("#{ruby_bin}/gem", "fetch", "shopify-cli", "--version", gem_version)
unless status.success?
odie err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

@@ -13,7 +13,7 @@
class ShopifyCli < Formula
module RubyBin
def ruby_bin
Formula["ruby"].opt_bin
Formula["ruby@3.0"].opt_bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably didn't see this on my system due to having Ruby 3.1 installed already. Thanks for fixing.

@amcaplan
Copy link
Contributor

I've approved the PR. It will still take a bit until it's merged and released, so @binarymonkey84 if you're in a rush you can try sudo gem install shopify-cli which should work.

The issue is that macOS comes bundled with Ruby but it's in a protected directory, /Library/Ruby, which also includes where you'd install gems. Prefacing with sudo adds admin permissions to circumvent the write protection.

Because we don't want to encourage overuse of sudo, we'd greatly prefer Mac users install via homebrew or using a ruby version manager (the most popular are chruby, rbenv, rvm). But if you do need to install on system Ruby, then sudo gem install shopify-cli is the only way it'll work.

@binarymonkey84
Copy link

Thanks for approving.

I'm using an Intel Mac (I went for Intel hardware by choice to reduce compatibility issues).

I was aware of the sudo option, but like you say it doesn't come recommended and from what I'd seen, the Internet seems to be saying "don't do that".

I will have a look at rbenv, but not knowing anything about Ruby, I wasn't sure if this would mess up the system Ruby, homebrew or even if it worked, whether having the gem install method is compatible with the homebrew install method...

It would probably be nice to update the Shopify docs to talk about this, or at least mention the preferred method is Homebrew (it's not first on the page).

I remember the first time I tried to install the CLI on an Intel Mac with Ruby, it went very wrong indeed. When I tried homebrew there was no issue (until this problem of course).

@pepicrft pepicrft merged commit a6d7bb8 into main Feb 14, 2022
@pepicrft pepicrft deleted the fix-homebrew-template branch February 14, 2022 09:40
@gonzaloriestra gonzaloriestra mentioned this pull request Feb 14, 2022
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems February 14, 2022 12:33 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants