DEV Community

chuongmep
chuongmep

Posted on

2 1 1 1

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

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

code .
Enter fullscreen mode Exit fullscreen mode

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

EACCES: permission denied, unlink '/usr/local/bin/code'
Enter fullscreen mode Exit fullscreen mode

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 fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Notes

  • This fix requires admin permissions to install the code command properly.
  • If you're using a non-admin account, you may need to ask your system administrator for help.

Now, you can happily use code . again without any issues! 🚀

Let me know in the comments if you run into any trouble! Happy coding! 😊

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (1)

Collapse
 
yuriystasiv profile image
Yuriy Stasiv

Thanks, that's helped me!

Eliminate Context Switching and Maximize Productivity

Pieces.app

Pieces Copilot is your personalized workflow assistant, working alongside your favorite apps. Ask questions about entire repositories, generate contextualized code, save and reuse useful snippets, and streamline your development process.

Learn more

👋 Kindness is contagious

If this post resonated with you, feel free to hit ❤️ or leave a quick comment to share your thoughts!

Okay