Fix EACCES: permission denied, unlink '/usr/local/bin/code'

If you're using macOS and trying to run the shortcut command: code . to open the current folder in VS Code, but you get a permission error like this: EACCES: permission denied, unlink '/usr/local/bin/code' then you're not alone! This issue is quite common and happens because the /usr/local/bin/code file requires administrative privileges to modify or delete. How to Fix It To resolve this issue, follow these steps: Step 1: Remove the Existing code Binary Since the file is in /usr/local/bin/, you'll need admin permissions to remove it. Run the following command in your terminal: sudo rm -f /usr/local/bin/code Enter your password when prompted. Step 2: Reinstall the code Command Now, reopen VS Code, then follow these steps: Open the Command Palette (Cmd + Shift + P). Search for Shell Command: Install 'code' command in PATH. Click on it to reinstall the CLI command. Step 3: Verify To confirm it's working, try running: code --version If you see the version number of VS Code, then it's fixed!

Mar 15, 2025 - 05:40
 0
Fix EACCES: permission denied, unlink '/usr/local/bin/code'

If you're using macOS and trying to run the shortcut command:

code .

to open the current folder in VS Code, but you get a permission error like this:

EACCES: permission denied, unlink '/usr/local/bin/code'

then you're not alone! This issue is quite common and happens because the /usr/local/bin/code file requires administrative privileges to modify or delete.

How to Fix It

To resolve this issue, follow these steps:

Step 1: Remove the Existing code Binary

Since the file is in /usr/local/bin/, you'll need admin permissions to remove it. Run the following command in your terminal:

sudo rm -f /usr/local/bin/code

Enter your password when prompted.

Step 2: Reinstall the code Command

Now, reopen VS Code, then follow these steps:

  1. Open the Command Palette (Cmd + Shift + P).
  2. Search for Shell Command: Install 'code' command in PATH.
  3. Click on it to reinstall the CLI command.

Step 3: Verify

To confirm it's working, try running:

code --version

If you see the version number of VS Code, then it's fixed!