Fix Operation Not Permitted Error in VSCode Terminal on macOS

2 min read

If the VSCode integrated terminal throws Operation not permitted when you run basic commands like ls or cat, the fix is simple: macOS is blocking VSCode from accessing certain directories. You need to grant it Full Disk Access.

Why This Happens

Since macOS Mojave (10.14), Apple restricts apps from accessing protected directories like ~/Desktop, ~/Documents, and ~/Downloads unless you explicitly allow it. The same commands work fine in Terminal.app or iTerm because those apps already have the permission — VSCode does not by default.

The error typically looks like this:

ls: .: Operation not permitted

Fix: Grant Full Disk Access to VSCode

1. Open System Settings

Click the Apple menu and select System Settings.

On macOS Monterey (12) or earlier, this is called System Preferences.

2. Go to Privacy & Security

In the sidebar, click Privacy & Security, then scroll down and click Full Disk Access.

Fix Operation Not Permitted Error in VSCode Terminal on macOS

On macOS Monterey or earlier: Security & Privacy > Privacy tab > Full Disk Access.

3. Add Visual Studio Code

Toggle the switch next to Visual Studio Code to enable it. If VSCode isn’t listed, click the + button, navigate to /Applications, and select Visual Studio Code.

You may need to authenticate with your password or Touch ID.

Fix Operation Not Permitted Error in VSCode Terminal on macOS

4. Restart VSCode

Quit VSCode completely (Cmd + Q) and reopen it. The permission change only takes effect after a restart.

Verify the Fix

Open the VSCode terminal and run a command that previously failed:

ls ~/Downloads

If it lists the directory contents without errors, the fix worked.

Still Not Working?

If the error persists after granting Full Disk Access and restarting:

  • Check the shell binary. If you use a custom shell (e.g., Zsh from Homebrew at /opt/homebrew/bin/zsh), that binary may also need Full Disk Access. Add it the same way.
  • Remove and re-add VSCode. In the Full Disk Access list, remove Visual Studio Code and add it again. Sometimes the permission gets stuck.
  • Check for VSCode Insiders. If you’re running VSCode Insiders, you need to add that specific app — it’s a separate entry from the stable build.

Conclusion

The “Operation not permitted” error in VSCode on macOS is a permissions issue, not a bug. Granting Full Disk Access resolves it instantly. If you also use VSCode with remote environments, check out How to Connect Visual Studio Code with WSL 2 for Linux Ubuntu or Global MCP Server Configuration in VS Code WSL: Fixing Startup Errors.