Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] Don't prompt users to brew cask install #6156

Conversation

issyl0
Copy link
Member

@issyl0 issyl0 commented May 21, 2019

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

  • I tried to install keybase, thinking I'd get the CLI, but no. On Linux,
    casks don't work, yet I was still prompted to brew cask install keybase. When I tried that (just to make sure), I got the "casks are
    only supported on MacOS" error.
  • This change makes it so we don't prompt people to install casks if
    they're on platforms other than MacOS.

Before:

$ brew install keybase
Error: No available formula with the name "keybase"
Found a cask named "keybase" instead.

After:

Error: No available formula with the name "keybase"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.

which is long, but still better messaging than "found a cask".

This is a draft PR. Things still to do include:

  • Tests. I can't find many places in the tests that differentiate between OSes. I might need some help here. 😬
  • This doesn't account for the cases where people try to install blacklisted formulae on Linux, for which the help text hardcodes "brew cask install". I'd welcome ideas on how to do this, because I couldn't see how to break the massive case statement up without excluding some formulae from either, using the common unless OS.mac? condition.

(I couldn't see anything in the contributing guide about whether draft PRs are good or not, so feel free to close this for that reason, or if this is not a feature you'd support!)

@@ -198,6 +200,7 @@ def deleted_reason(name, silent: false)

def cask_reason(name, silent: false, show_info: false)
return if silent
return unless OS.mac?
Copy link
Member

Choose a reason for hiding this comment

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

Ideally this would be a no-op method and have this method implementation moved to Library/Homebrew/extend/os/mac/missing_formula.rb instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I'm not sure I understand what you mean?

Copy link
Member

Choose a reason for hiding this comment

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

Check out the other files in Library/Homebrew/extend/os/mac. We generally prefer taking that approach of extending the initial class to adding OS.mac? checks around the codebase.

Copy link
Member Author

@issyl0 issyl0 May 21, 2019

Choose a reason for hiding this comment

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

Thanks. I've done this in 5bf5ea2 which I'll squash at the end if everything's OK.

@issyl0 issyl0 force-pushed the dont_show_missing_formula_cask_info_on_linux branch 2 times, most recently from 5bf5ea2 to ce54f07 Compare May 22, 2019 22:09
module MissingFormula
class << self
def cask_reason(*)
# Casks aren't supported on non-MacOS.
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I should have explained this better but I was hoping for the reverse e.g. in os/mac/missing_formula.rb. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah! 😳To be sure I understand the intended outcome for "reversing" this, I have a couple of questions as there are several approaches going around in my head:

Copy link
Member

Choose a reason for hiding this comment

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

Yup, this, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for confirming. I've tested manually that it still works as intended on both MacOS and Linux, and pushed the new changes.

@issyl0 issyl0 force-pushed the dont_show_missing_formula_cask_info_on_linux branch 4 times, most recently from b1363fb to 9ecdc7f Compare May 24, 2019 20:22
@issyl0
Copy link
Member Author

issyl0 commented May 24, 2019

I tried to write tests for this new behaviour, then I realised that cask_reason is a cask method so won't run on non-MacOS anyway. So I'm not changing any behaviour test-wise, which is why I wasn't seeing any changes.

In terms of what's left here, half of this still depends on the linuxbrew-core PR, otherwise I think that's all the review comments dealt with?

Thanks for your patience!

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Almost there, thanks again!

Library/Homebrew/missing_formula.rb Show resolved Hide resolved
Library/Homebrew/missing_formula.rb Outdated Show resolved Hide resolved
- I tried to install `keybase`, thinking I'd get the CLI. On Linux,
  casks don't work, yet I was still prompted to `brew cask install
  keybase`. When I tried that (just to make sure), I got the "casks are
  only supported on MacOS" error.
- This change makes it so we don't prompt people to install casks if
  they're on platforms other than MacOS.

Before:

```
╭─issyl0@grus /home/linuxbrew/.linuxbrew/Homebrew ‹master›
╰─ $ brew install keybase
Error: No available formula with the name "keybase"
Found a cask named "keybase" instead.
```

After:

```
Error: No available formula with the name "keybase"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
```
@issyl0 issyl0 force-pushed the dont_show_missing_formula_cask_info_on_linux branch from 9ecdc7f to 4a5b026 Compare May 25, 2019 14:46
@issyl0
Copy link
Member Author

issyl0 commented May 25, 2019

Thanks, @MikeMcQuaid. I've pushed changes for your last two comments. :-)

@MikeMcQuaid
Copy link
Member

Perfect, thanks again for the great work @issyl0, you rock!

@MikeMcQuaid MikeMcQuaid merged commit 515aef9 into Homebrew:master May 26, 2019
@issyl0 issyl0 deleted the dont_show_missing_formula_cask_info_on_linux branch May 26, 2019 08:48
@lock lock bot added the outdated PR was locked due to age label Jan 1, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants