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

Remove launchjob files during uninstall, even if they are not loaded #14730

Merged
merged 2 commits into from Oct 28, 2015
Merged

Remove launchjob files during uninstall, even if they are not loaded #14730

merged 2 commits into from Oct 28, 2015

Conversation

jawshooah
Copy link
Contributor

This fixes the original implementation in #8523 to correctly remove user launchjob files, and to do so even when the jobs have not been loaded.

Fixes #14728

Review on Reviewable

@jawshooah jawshooah added the awaiting maintainer feedback Issue needs response from a maintainer. label Oct 28, 2015
paths = paths.map { |elt| Pathname(elt) }.select(&:exist?)
paths.each do |path|
@command.run!('/bin/rm', :args => ['-f', '--', path], :sudo => with_sudo)
end
plist_status = @command.run('/bin/launchctl', :args => ['list', service], :sudo => with_sudo, :print_stderr => false).stdout
if %r{^\{}.match(plist_status)
result = @command.run!('/bin/launchctl', :args => ['remove', service], :sudo => with_sudo)
Copy link
Contributor

Choose a reason for hiding this comment

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

@jawshooah thanks for a fix!
is there any specific reason to rm .plist file and only then launchctl remove?

This is a reversal of previous flow and feels unnatural.
I'd assume it works just fine, but we shouldn't expect this to continue working if Apple rewrites launchctl daemon once again.
It feels safer and further-proof to launchctl remove first and only then rm .plist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. I tested locally and there were no problems, but there's no guarantee that won't change. Thanks for the review!

Pathname does not expand '~', so we need to give it the absolute path to
the HOME directory.
@vitorgalvao
Copy link
Member

Looks fine to me. We should cut a release after this is in (there were other small fixes in the meantime as well)

jawshooah added a commit that referenced this pull request Oct 28, 2015
Remove launchjob files during uninstall, even if they are not loaded
@jawshooah jawshooah merged commit 8c9d3ec into Homebrew:master Oct 28, 2015
@jawshooah jawshooah deleted the fix-uninstall-launchctl branch October 28, 2015 17:58
@vitorgalvao
Copy link
Member

Are you cutting the new release, or do you want me to do it?

@jawshooah
Copy link
Contributor Author

Took care of it myself.

@adidalal adidalal removed the awaiting maintainer feedback Issue needs response from a maintainer. label Jan 3, 2016
@Homebrew Homebrew locked and limited conversation to collaborators May 8, 2018
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.

Launchctl uninstall do not clean-up users LaunchAgents .plist files
4 participants