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! 🎉
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! 😊
Top comments (1)
Thanks, that's helped me!