Skip to content

Conversation

@tallpsmith
Copy link
Contributor

Summary

This PR modernizes the macOS uninstaller to fix critical issues reported in #2347 and implements all recommendations from @natoscott.

Problem

The current uninstall-pcp script has several critical issues:

  1. Obsolete service management: Uses /Library/StartupItems which hasn't existed on macOS for years
  2. Missing services: Only handled pmcd and pmlogger, ignoring pmie and pmproxy
  3. Outdated package removal: Used old receipt locations instead of modern pkgutil
  4. Incomplete cleanup: Left ~80+ directories with "Directory not empty" errors
  5. Insecure temp files: Used hardcoded /tmp paths
  6. No force option: No way to do complete cleanup including config/data/logs

Changes

This PR addresses all issues through 4 logical commits:

Commit 1: Fix pmproxy plist typo

  • Fixed GNUmakefile where pmproxy was incorrectly installing pmlogger.plist

Commit 2: Modernize service management

  • Replace obsolete /Library/StartupItems with modern launchctl commands
  • Support both bootout (macOS 10.11+) and unload for compatibility
  • Add support for all 4 services: pmcd, pmie, pmlogger, pmproxy
  • Use pkgutil --forget for modern package receipt management
  • Explicitly remove LaunchDaemons plist files
  • Preserve config/log files with user notification

Commit 3: Add force mode and mktemp

  • Use mktemp(1) for secure temp directory creation
  • Add -f/--force flag to skip confirmation and perform complete removal
  • Add --help flag for usage information
  • Implement aggressive cleanup in force mode that removes:
    • /etc/pcp/
    • /var/lib/pcp/
    • /var/log/pcp/

Commit 4: Documentation

  • Add HOMEBREW_TAP_UPDATES.md with recommendations for aligning Homebrew tap
  • Add TESTING_GUIDE.md with comprehensive testing procedures
  • Document force mode usage and testing strategies

Testing

Standard uninstall preserves config/logs:

sudo /usr/local/libexec/pcp/bin/uninstall-pcp

Force mode removes everything:

sudo /usr/local/libexec/pcp/bin/uninstall-pcp --force

See build/mac/TESTING_GUIDE.md for comprehensive testing procedures.

Impact

  • Fixes: All service management issues in macOS Uninstall PCP #2347
  • Solves: "Directory not empty" errors with force mode
  • Improves: Security with mktemp
  • Adds: User choice for config/log preservation
  • Maintains: Backward compatibility with fallback launchctl commands

Notes

This PR is marked as DRAFT for manual testing on macOS VMs before final review.

Fixes #2347

tallpsmith and others added 5 commits December 5, 2025 12:03
The pmproxy service was incorrectly installing io.pcp.pmlogger.plist
instead of io.pcp.pmproxy.plist, causing the pmproxy service to use
the wrong configuration.

Issue performancecopilot#2347
- Replace obsolete /Library/StartupItems with modern launchctl commands
- Support both 'bootout' (macOS 10.11+) and 'unload' for compatibility
- Add support for all 4 services: pmcd, pmie, pmlogger, pmproxy
  (previously only handled pmcd and pmlogger)
- Use pkgutil for modern package receipt management
- Explicitly remove LaunchDaemons plist files
- Preserve config/log files with user notification

This addresses the core service management issues reported in performancecopilot#2347
where the uninstaller failed because StartupItems no longer exist on
modern macOS systems.

Issue performancecopilot#2347
- Use mktemp(1) for secure temp directory creation instead of
  hardcoded /tmp paths
- Add -f/--force flag to skip confirmation prompt and perform
  complete removal including config/data/log directories
- Add --help flag for usage information
- Implement selective aggressive cleanup in force mode that removes
  /etc/pcp/, /var/lib/pcp/, and /var/log/pcp/

This addresses Nathan Scott's recommendations in performancecopilot#2347 and solves
the "Directory not empty" errors by providing a force mode that
removes all PCP-related directories even when they contain files
created post-installation.

Issue performancecopilot#2347
- Add HOMEBREW_TAP_UPDATES.md with recommendations for aligning the
  Homebrew tap with .pkg uninstaller improvements
- Add TESTING_GUIDE.md with comprehensive manual and automated testing
  procedures for macOS uninstallation
- Document force mode usage and testing procedures
- Include UTM-based testing strategies and CI/CD recommendations

Issue performancecopilot#2347
…mode

In force mode, the install-pcp script's "Directory not empty" warnings
are confusing since we're about to forcefully remove those directories
with rm -rf anyway. Redirect stderr to /dev/null for install-pcp when
running in force mode to provide cleaner output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@tallpsmith tallpsmith marked this pull request as ready for review December 5, 2025 05:36
@tallpsmith tallpsmith requested a review from natoscott December 5, 2025 05:40
@tallpsmith
Copy link
Contributor Author

@natoscott I think this is good to review and merge if you're ok with it. I've tested manually both force and non-force modes in a UTM VM, they seem to be good. I am going to now aim to integrate any necessary changes into the Homebrew cask repo so that it can uninstall things cleanly there.

@tallpsmith tallpsmith added the macOS For issues specific or related to macOS label Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macOS For issues specific or related to macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS Uninstall PCP

1 participant