Home/Troubleshooting/Claude Code: Operation not permitted when accessing the Desktop or Documents folder on Mac

Claude Code: Operation not permitted when accessing the Desktop or Documents folder on Mac

Updated · airankrush

Symptom

Claude Code returns Operation not permitted when it runs ls, cat or writes a file, even though you are an administrator of this Mac and the files are your own. Opening the same folder in Finder works fine.

Possible causes (most common first)

  1. macOS privacy protection: locations such as Desktop, Documents and Downloads need to be granted per app. Claude Code runs in a terminal and macOS looks at the terminal app. Either it has not been granted access, or Don't Allow was clicked when the prompt first appeared.
  2. The location is under stricter protection, for example Mail, Messages or Safari data, or Time Machine backups, and requires Full Disk Access.
  3. Claude Code's sandbox feature is on. Commands inside the sandbox can by default write only to the working directory and temporary directories, and writing elsewhere gives this error.
  4. The target really does belong to another account or to the system, for example the platform management account's folders. That is normal permission isolation, not a fault.

Troubleshooting steps (easiest first)

  1. First tell whether macOS or the sandbox is blocking it

    Quit Claude Code and run the same command by hand in the same terminal, for example ls ~/Desktop. If it fails by hand too, it is macOS privacy protection. If it works by hand and fails only inside Claude Code, look at the sandbox. Type /sandbox in Claude Code to see the sandbox status. According to the official documentation, the sandbox is off by default, and when it is on, the typical error on macOS is exactly Operation not permitted.

  2. The easiest fix: move the project out of the protected folders

    Keep your code in an ordinary folder under your home folder, for example ~/code or ~/projects, not in Desktop, Documents or Downloads. Ordinary folders are outside privacy protection, so Terminal and Claude Code can read and write them with no permission grant at all, and nothing breaks later when a system update invalidates a grant.

  3. You need those folders: grant access to the terminal

    Open System Settings → Privacy & Security → Files & Folders, find the terminal program you use (Terminal, iTerm2, or VS Code and similar editors), turn on the switch for the folder in question, then fully quit and reopen that terminal program. See Apple Support: Control access to files and folders on Mac. If your terminal is not in the list, it has not requested access yet. Run the access command once more in the terminal and click Allow when the system prompt appears.

  4. Full Disk Access: think before granting it

    Full Disk Access, on the same settings page, lets the terminal reach every file on this Mac. According to Apple's explanation, that includes data from other apps and certain administrative settings for all users. Granting it to a terminal grants it to every program run in that terminal, including AI tools that execute commands on their own. Unless you truly need it, turn on only the specific items under Files & Folders.

  5. Blocked by the sandbox: add the directory to the allowed scope

    Once you have confirmed the sandbox is the cause, use /add-dir to add the directory you need to the working scope, or add the path under sandbox.filesystem.allowWrite in the settings file. For the exact field syntax, go by the official documentation. Claude Code sometimes proposes retrying a command outside the sandbox; whether to agree is your decision.

When to contact support directly

Contact support on Contact support when: the switches under Privacy & Security are greyed out or said to be controlled by a management profile; ordinary folders under your own home folder give this error too; or the remote connection misbehaves after you grant the terminal access. Include your machine ID, macOS version, the terminal program's name, and the full failing command and path. Being unable to reach the folders of the platform's management account or system management components is expected; do not try to change their permissions. For problems in Claude Code itself, report them as its official documentation describes.

Pricing and availability: see the plans page · Help center (中文) · Refund policy (中文) · Telegram Contact support

Back to home · All troubleshooting pages