-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
[Linux] Don't prompt users to brew cask install
#6156
Conversation
Library/Homebrew/missing_formula.rb
Outdated
@@ -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? |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
5bf5ea2
to
ce54f07
Compare
module MissingFormula | ||
class << self | ||
def cask_reason(*) | ||
# Casks aren't supported on non-MacOS. |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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:
- The current
missing_formula.rb
cask_reason
code is moved into theextend/os/mac/missing_formula.rb
so that it's only called on MacOS, and for the original method call to be scoped toOS.mac?
? - The
extend/os/mac/missing_formula.rb
is changed toreturn if OS.linux?
? But the Mac extend file is onlyrequire
d if already on MacOS, so Linux would never get there. - Or, something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The current
missing_formula.rb
cask_reason
code is moved into theextend/os/mac/missing_formula.rb
so that it's only called on MacOS
Yup, this, thanks!
There was a problem hiding this comment.
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.
b1363fb
to
9ecdc7f
Compare
I tried to write tests for this new behaviour, then I realised that 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! |
There was a problem hiding this 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!
- 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. ```
9ecdc7f
to
4a5b026
Compare
Thanks, @MikeMcQuaid. I've pushed changes for your last two comments. :-) |
Perfect, thanks again for the great work @issyl0, you rock! |
brew style
with your changes locally?brew tests
with your changes locally?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 areonly supported on MacOS" error.
they're on platforms other than MacOS.
Before:
After:
which is long, but still better messaging than "found a cask".
This is a draft PR. Things still to do include:
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!)