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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gitify): add preflight steps to reduce errors during brew upgrade #173061

Merged
merged 6 commits into from May 14, 2024

Conversation

setchy
Copy link
Contributor

@setchy setchy commented May 7, 2024

Important: Do not tick a checkbox if you haven鈥檛 performed its action. Honesty is indispensable for a smooth review process.

In the following questions <cask> is the token of the cask you're submitting.

After making any changes to a cask, existing or new, verify:

Additionally, if adding a new cask:

  • Named the cask according to the token reference.
  • Checked the cask was not already refused.
  • Checked the cask is submitted to the correct repo.
  • brew audit --cask --new <cask> worked successfully.
  • HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask <cask> worked successfully.
  • brew uninstall --cask <cask> worked successfully.

Appreciate any wisdom from the maintainers. 馃檹

We've been seeing the error documented at gitify-app/gitify#918 when performing a brew upgrade for Gitify.

My most recent theory is it's due to the previous Gitify.app is left running which causes the resource not found issue.

@bevanjkay
Copy link
Member

bevanjkay commented May 7, 2024

This is a known and somewhat expected issue. We have changed the way the uninstall quit stanzas work so that they do not fire on brew upgrade. This is because it may not be expected for an app to be forcibly closed resulting in the loss of unsaved work.
In the case of gitify it may be safe to forcibly close this, but it is likely best to instruct the user to restart the app themselves after an upgrade. They would have had to have reopened it anyway.

The other option which was discussed to a certain level, was adding an option to uninstall quit that does fire on brew upgrade in cases where it is known to be safe.

@setchy
Copy link
Contributor Author

setchy commented May 7, 2024

Thanks for the speedy reply, @bevanjkay 馃檱

In the case of Gitify, closing the app will be fine since we're always pulling state from GitHub.

If force quiting the app helps remove/reduce the unexpected errors, then that's a win imho

I've also added a postflight script to relaunch the app.

The other option which was discussed to a certain level, was adding an option to uninstall quit that does fire on brew upgrade in cases where it is known to be safe.

Nice! Yes, this would be cleaner for cask maintainers to opt-in where safe. Even better, if the app could be relaunched afterwards, too

@setchy setchy changed the title fix(gitify): attempt to reduce image errors during brew upgrade fix(gitify): add preflight/postflight steps to reduce image errors during brew upgrade May 7, 2024
@setchy setchy changed the title fix(gitify): add preflight/postflight steps to reduce image errors during brew upgrade fix(gitify): add preflight/postflight steps to reduce errors during brew upgrade May 7, 2024
Casks/g/gitify.rb Outdated Show resolved Hide resolved
Comment on lines +17 to +25
preflight do
retries ||= 3
ohai "Attempting to close Gitify.app to avoid unwanted user intervention" if retries >= 3
return unless system_command "/usr/bin/pkill", args: ["-f", "/Applications/Gitify.app"]
rescue RuntimeError
sleep 1
retry unless (retries -= 1).zero?
opoo "Unable to forcibly close Gitify.app"
end
Copy link
Member

Choose a reason for hiding this comment

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

I'm okay with this in principle, but I think we would be better off adjusting the uninstall quit dsl to allow for this use case. If we add a preflight block here that closes the app, it sets a precedent to customise this in other casks. We try to avoid preflight/postflight blocks as much as possible and are looking to remove them. We should file an issue at github.com/homebrew/brew to track the idea of allowing certain apps to be quit forcibly first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While discussion on DSL changes continues on Homebrew/brew#17247, would it be possible to move forward with this fix @bevanjkay.

Happy to pivot once the alternate route is available

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I guess it's the best option for now. I was hoping for a second opinion from another maintainer, I'll see if I can get one.

@setchy setchy changed the title fix(gitify): add preflight/postflight steps to reduce errors during brew upgrade fix(gitify): add preflight steps to reduce errors during brew upgrade May 9, 2024
@setchy setchy requested a review from bevanjkay May 9, 2024 01:10
@bevanjkay bevanjkay added the awaiting maintainer feedback Issue needs response from a maintainer. label May 9, 2024
@setchy
Copy link
Contributor Author

setchy commented May 14, 2024

@bevanjkay - we're planning a new release of Gitify this week. Do you think this can proceed in its current form?

@bevanjkay bevanjkay added ready to merge PR can be merged once CI is green and removed awaiting maintainer feedback Issue needs response from a maintainer. labels May 14, 2024
@miccal miccal merged commit e94b574 into Homebrew:master May 14, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge PR can be merged once CI is green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants