macOS LaunchAgent Blocked from ~/Documents Due to Privacy Context, Not File Permissions
A zsh script that successfully listed the ~/Documents folder in macOS Terminal failed with an 'Operation not permitted' error when run as a LaunchAgent under launchd, despite identical user IDs and home directory paths. Testing on macOS 15.6.1 revealed that the access denial was tied to the process launch context, not file ownership or permission bits, since the LaunchAgent could read other directories owned by the same user. macOS enforces a privacy context for protected folders like Documents, Desktop, and Downloads, and processes started by launchd do not inherit the same privacy access granted to interactive Terminal sessions. A negative control path outside the protected folder succeeded in both contexts, confirming that chmod or ownership changes would not resolve the issue. Developers diagnosing similar failures are advised to compare access from both launch contexts, use a control path outside protected folders, and enable pipefail in zsh scripts to avoid masked errors from pipeline status misreporting.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in