Comprehensive solutions for common issues and errors.
Error:
$ macos-cleaner
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.13/bin/macos-cleaner", line 3, in <module>
from main import main
ModuleNotFoundError: No module named 'main'Root Cause: Package entry point can't find the main module
Solution:
# Method 1: Reinstall package
pip uninstall MacCleanCLI
pip install -e .
# Method 2: Verify setup.py contains py_modules
# setup.py should have:
# py_modules=['main'],
# Method 3: Run directly with Python
python main.pyVerify Fix:
# Both commands should work
macos-cleaner --help
mclean --helpError:
$ macos-cleaner
-bash: macos-cleaner: command not foundRoot Cause: Python scripts directory not in PATH or package not installed
Solution:
# Step 1: Check if package is installed
pip show MacCleanCLI
# Step 2: Find where scripts are installed
which python
pip show MacCleanCLI | grep Location
# Step 3: Add Python scripts to PATH (if needed)
# For zsh (macOS default):
echo 'export PATH="/Library/Frameworks/Python.framework/Versions/3.13/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# For bash:
echo 'export PATH="/Library/Frameworks/Python.framework/Versions/3.13/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
# Step 4: Reinstall if needed
pip install -e .Workaround:
# Use direct Python execution
python main.pyError:
ERROR: Could not install packages due to an OSError: [Errno 13] Permission deniedSolution:
# Option 1: Install in user mode (recommended)
pip install --user -e .
# Option 2: Use virtual environment (best practice)
python -m venv venv
source venv/bin/activate
pip install -e .
# Option 3: Fix permissions (if necessary)
sudo chown -R $(whoami) ~/.local/lib/python*/site-packages
pip install -e .Error:
PermissionError: [Errno 1] Operation not permitted: '/System/Library/Caches'Root Cause: macOS System Integrity Protection (SIP) or missing Full Disk Access
Solution:
Step 1: Grant Full Disk Access
- Open System Settings (macOS Ventura+) or System Preferences (older)
- Navigate to Privacy & Security → Full Disk Access
- Click 🔒 to unlock
- Click + button
- Add your Terminal app:
/Applications/Utilities/Terminal.app/Applications/iTerm.app(if using iTerm2)
- Restart Terminal
- Re-run
macos-cleaner
Step 2: Verify Permissions
# Test access to common directories
ls -la ~/Library/Caches/ # Should list files
ls -la /Library/Caches/ # Should list files
ls -la /var/folders/ # Should list files
# If still denied, check SIP status
csrutil statusStep 3: Alternative for System Paths
# Some system paths require sudo
sudo macos-cleaner --scan-only
# Warning: Not recommended for regular use
# Only use sudo for one-time system scansProblem: Browser cache scan returns 0 files
Root Cause: Browser-specific permissions or browsers are running
Solution:
Step 1: Close All Browsers
# Close all browser instances
killall Safari Chrome Firefox Brave "Google Chrome" "Microsoft Edge"Step 2: Verify Cache Locations
# Check if cache directories exist
ls -la ~/Library/Caches/com.apple.Safari/
ls -la ~/Library/Caches/Google/Chrome/
ls -la ~/Library/Caches/Firefox/
ls -la ~/Library/Caches/BraveSoftware/Step 3: Grant Permissions
# If directories exist but can't read:
chmod -R u+r ~/Library/Caches/
# For stubborn caches, check extended attributes
xattr -d com.apple.quarantine ~/Library/Caches/* 2>/dev/nullBrowser-Specific Paths:
- Safari:
~/Library/Caches/com.apple.Safari/ - Chrome:
~/Library/Caches/Google/Chrome/Default/Cache/ - Firefox:
~/Library/Caches/Firefox/Profiles/*/cache2/ - Brave:
~/Library/Caches/BraveSoftware/Brave-Browser/Default/Cache/ - Edge:
~/Library/Caches/Microsoft Edge/Default/Cache/
Problem: Clean operation completes but files still exist
Root Cause: Files in use, protected, or verification failed
Diagnosis:
# Check application logs
cat ~/.macos-cleaner/logs/cleaner_*.log | grep -i "failed\|error"
# Check if files are in use
lsof +D ~/Library/Caches/ | head -20Solutions:
1. Close Applications Using Files:
# Identify processes
lsof ~/Library/Caches/* | awk '{print $1}' | sort -u
# Close specific apps
killall Safari Spotify Chrome2. Enable Dry Run to Test:
# Test what would be deleted
macos-cleaner --dry-run3. Check Protected Paths:
# View protected paths in config
cat ~/.MacCleanCLI/config.json | jq '.protected_directories'
# Files in protected paths are never deleted4. Verify Backup System:
# If backup enabled, files moved here:
ls -la ~/.macos-cleaner/backups/
# Restore if needed
cp -r ~/.macos-cleaner/backups/YYYY-MM-DD_HHMMSS/* /original/location/Error:
CleaningError: Failed to delete 45 files
See logs for details: ~/.macos-cleaner/logs/Investigation:
# Check detailed logs
tail -50 ~/.macos-cleaner/logs/cleaner_$(date +%Y%m%d).log
# Common reasons in logs:
# - "Permission denied" → Need sudo or Full Disk Access
# - "File in use" → Close applications
# - "No such file or directory" → File deleted between scan and cleanSolutions by Error Type:
Permission Errors:
# Grant Full Disk Access (see Issue 4)
# Or use sudo for specific clean:
sudo macos-cleaner --autoFiles in Use:
# Close all applications
osascript -e 'tell application "System Events" to set quitapps to name of every application process whose visible is true and name is not "Finder"'
# Quit specific app
osascript -e 'quit app "Safari"'Path Doesn't Exist:
# File was already deleted or moved
# This is safe to ignore, check verification summaryProblem: Scan completes but reports 0 files
Diagnosis:
# Check if system is actually clean
du -sh ~/Library/Caches/
du -sh /Library/Caches/
du -sh ~/Library/Developer/Xcode/DerivedData/ 2>/dev/null
# Check minimum file size filter
cat ~/.MacCleanCLI/config.json | jq '.min_file_size_mb'Solutions:
1. Lower File Size Threshold:
# Edit config to scan smaller files
nano ~/.MacCleanCLI/config.json
# Change: "min_file_size_mb": 0.0001 (100 bytes)2. Enable Hidden Files:
{
"scan_hidden_files": true
}3. Check Specific Paths:
# Manually verify cache directories exist
ls -la ~/Library/Caches/ | head -20
ls -la ~/Library/Developer/Xcode/DerivedData/ 2>/dev/null
ls -la ~/Library/Containers/*/Data/Library/Caches/ 2>/dev/null4. Run Verbose Scan:
macos-cleaner --scan-only --verbose
# Check output for skipped paths or errorsProblem: Scanning takes >10 minutes
Root Cause: Large external drives, network shares, or low worker count
Solutions:
1. Increase Worker Threads:
# Edit config file
nano ~/.MacCleanCLI/config.json
# Change: "max_workers": 8
# Default is 4, try 6-8 for faster scans2. Exclude Network Drives:
# Unmount network shares during scan
# Or create custom config excluding them3. Monitor Progress:
# Run with verbose mode to see what's being scanned
macos-cleaner --scan-only --verbose
# Check system resources
top -l 1 | grep macos-cleaner4. Scan Specific Categories Only:
# Instead of scanning all, choose specific categories
# In interactive mode: Select categories individually
# This is much faster for targeted cleaningError:
OptimizationError: Failed to purge memory: [Errno 1] Operation not permittedRoot Cause: Memory purge requires admin privileges
Solution:
# Memory purge requires sudo
sudo purge
# Or run optimization with sudo
sudo macos-cleaner
# Then select: [3] Optimize System → [1] Purge MemoryAlternative (no sudo needed):
# Force applications to release memory
# Close memory-intensive apps:
killall -HUP Safari Chrome Spotify
# Check current memory usage
vm_stat
# Restart computer (most effective)
sudo shutdown -r nowError:
Failed to disable startup item: com.example.serviceRoot Cause: SIP protection or insufficient permissions
Solutions:
1. Check Item Type:
# User LaunchAgents (can modify):
ls -la ~/Library/LaunchAgents/
# System LaunchAgents (require sudo):
ls -la /Library/LaunchAgents/
# System LaunchDaemons (require sudo):
ls -la /Library/LaunchDaemons/2. Disable via System Preferences:
# For Login Items:
# System Settings → Users & Groups → Login Items
# Remove items manually3. Manual Disable:
# For user agents
launchctl unload ~/Library/LaunchAgents/com.example.service.plist
# For system agents (requires sudo)
sudo launchctl unload /Library/LaunchAgents/com.example.service.plist
# For daemons (requires sudo)
sudo launchctl unload /Library/LaunchDaemons/com.example.service.plistError:
Failed to rebuild Spotlight indexSolution:
# Complete Spotlight rebuild (requires sudo)
# Step 1: Stop indexing
sudo mdutil -a -i off
# Step 2: Delete index (this is normal and safe)
sudo rm -rf /.Spotlight-V100
# Step 3: Restart indexing
sudo mdutil -a -i on
# Step 4: Force reindex specific volume
sudo mdutil -E /
# Step 5: Check status
mdutil -s /
# Should show: "Indexing enabled"
# Wait 10-30 minutes for reindex to completeVerify:
# Check indexing progress
sudo fs_usage -w -f filesys mds mdworker | grep -i spotlight
# Or check Spotlight preferences
# System Settings → Spotlight → Search ResultsProblem: Docker data category shows 0 files or errors
Solutions:
1. Docker Not Running:
# Start Docker
open -a Docker
# Or use Docker CLI
docker info2. Clean Docker Manually:
# Stop all containers
docker stop $(docker ps -aq)
# Remove all containers
docker rm $(docker ps -aq)
# Remove unused images
docker image prune -a
# Remove all unused data
docker system prune -a --volumes
# Check space saved
docker system df3. Docker Desktop Settings:
# Open Docker Desktop → Preferences → Resources → Advanced
# Clean up via UI: "Clean / Purge Data"Problem: Xcode category finds nothing
Verification:
# Check if directory exists
ls -la ~/Library/Developer/Xcode/DerivedData/
# Check disk space used
du -sh ~/Library/Developer/Xcode/DerivedData/
# Check archives
du -sh ~/Library/Developer/Xcode/Archives/Solutions:
1. If Xcode Not Installed:
# Category will show 0 files (expected)
# Skip this category2. If Xcode Installed but No Data:
# Build a project to generate DerivedData
# Or clean from Xcode:
# Xcode → Product → Clean Build Folder (⌘⇧K)3. Manual Cleanup:
# Safe to delete DerivedData
rm -rf ~/Library/Developer/Xcode/DerivedData/*
# Xcode will regenerate on next buildProblem: node_modules not being detected
Root Cause: Requires directory traversal or specific path
Verification:
# Find all node_modules directories
find ~ -name "node_modules" -type d 2>/dev/null | head -20
# Check total size
du -sh ~/Projects/*/node_modules/ 2>/dev/nullSolutions:
1. Scan from Project Root:
# Ensure scanning from home directory
# App should find all node_modules under ~/
# If not, check config:
cat ~/.MacCleanCLI/config.json2. Manual Cleanup:
# Clean specific project
cd ~/Projects/my-project
rm -rf node_modules
npm install # Reinstall if needed
# Clean all old projects (use with caution!)
find ~/Projects -name "node_modules" -type d -mtime +90 -exec rm -rf {} \;3. Use npm:
# Clean npm cache
npm cache clean --force
# Clean specific project
cd ~/Projects/my-project
npm ci # Clean installDiagnosis:
# Check crash logs
ls -lt ~/Library/Logs/DiagnosticReports/Python* | head -5
# Check application logs
tail -100 ~/.macos-cleaner/logs/cleaner_*.log
# Check system log
log show --predicate 'process == "Python"' --last 1hSolutions:
1. Clear Application Data:
# Remove config (will recreate with defaults)
rm ~/.MacCleanCLI/config.json
# Remove logs
rm ~/.macos-cleaner/logs/*
# Remove backups (optional, only if space needed)
rm -rf ~/.macos-cleaner/backups/*2. Reinstall Application:
# Complete reinstall
pip uninstall MacCleanCLI
rm -rf ~/Library/Python/*/site-packages/macos_cleaner*
pip install -e .3. Check Python Version:
# Requires Python 3.10+
python --version
# Upgrade if needed
brew upgrade python4. Check Dependencies:
# Verify all dependencies installed
pip list | grep -E "rich|psutil|click"
# Reinstall if missing
pip install rich psutil clickError:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)Solution:
# Backup current config
cp ~/.MacCleanCLI/config.json ~/.MacCleanCLI/config.json.bak
# Remove corrupted config
rm ~/.MacCleanCLI/config.json
# Run app to generate new config
macos-cleaner
# Or create valid config manually
cat > ~/.MacCleanCLI/config.json << 'EOF'
{
"dry_run": false,
"enable_backup": true,
"verify_cleaning": true,
"remove_empty_dirs": true,
"max_workers": 4,
"backup_retention_days": 7,
"min_file_size_mb": 0.001,
"scan_hidden_files": false
}
EOF# Create debug configuration
cat > ~/.MacCleanCLI/debug_config.json << 'EOF'
{
"dry_run": true,
"verbose": true,
"log_level": "DEBUG",
"enable_backup": true,
"max_workers": 2
}
EOF
# Run with debug config
macos-cleaner --config ~/.MacCleanCLI/debug_config.json --verbose
# View detailed logs
tail -f ~/.macos-cleaner/logs/cleaner_$(date +%Y%m%d).log# System information
sw_vers
python --version
pip list | grep -E "MacCleanCLI|rich|psutil"
# Disk space
df -h
# Permission check
ls -la ~/Library/Caches/ | head -5
ls -la /Library/Caches/ | head -5
# Config check
cat ~/.MacCleanCLI/config.json
# Recent errors
tail -100 ~/.macos-cleaner/logs/*.log | grep -i error1. Restore from Backup:
# List available backups
ls -lt ~/.macos-cleaner/backups/
# Restore specific backup
cp -r ~/.macos-cleaner/backups/2024-10-06_170000/* ~/
# Or restore specific file
cp ~/.macos-cleaner/backups/2024-10-06_170000/Library/Caches/somefile ~/Library/Caches/2. Use Time Machine:
# Enter Time Machine
# Navigate to deleted files
# Restore files
# Or via command line
tmutil listbackups
tmutil restore /path/to/backup/file /restore/location3. Stop Application Immediately:
# Kill all instances
killall -9 Python macos-cleaner
# Check for background processes
ps aux | grep macos-cleaner4. Reset to Factory State:
# Complete reset
rm -rf ~/.MacCleanCLI/
rm -rf ~/.macos-cleaner/
pip uninstall MacCleanCLI
pip install -e .Before reporting a bug, gather this information:
# 1. System Information
sw_vers > ~/debug-report.txt
echo "\n=== Python Version ===" >> ~/debug-report.txt
python --version >> ~/debug-report.txt
# 2. Package Information
echo "\n=== Package Info ===" >> ~/debug-report.txt
pip show MacCleanCLI >> ~/debug-report.txt
# 3. Configuration
echo "\n=== Configuration ===" >> ~/debug-report.txt
cat ~/.MacCleanCLI/config.json >> ~/debug-report.txt
# 4. Recent Logs
echo "\n=== Recent Errors ===" >> ~/debug-report.txt
tail -50 ~/.macos-cleaner/logs/*.log | grep -i error >> ~/debug-report.txt
# 5. Permissions
echo "\n=== Permissions ===" >> ~/debug-report.txt
ls -la ~/Library/Caches/ | head -10 >> ~/debug-report.txt
# View report
cat ~/debug-report.txtInclude:
- macOS version
- Python version
- Installation method
- Full error message
- Steps to reproduce
- Config file content (remove sensitive data)
- Relevant log excerpts
- Search existing issues before creating new ones
- Provide debug information from checklist above
- Be specific about what you expected vs what happened
- Include screenshots if UI-related
-
System Integrity Protection (SIP)
- Cannot modify SIP-protected files
- Some system directories are read-only
- This is by design for system security
-
iCloud Files
- Downloaded iCloud files may reappear after deletion
- iCloud syncs deleted items back
-
Active Files
- Cannot delete files currently in use
- Close applications before cleaning
-
Permissions
- Some operations require admin access
- Full Disk Access needed for complete scan
-
File Size Detection
- Minimum 1KB for general scanning
- 100KB minimum for duplicate detection
- Adjustable via config
Still having issues? Open an issue on GitHub
Made with ❤️ for macOS users