VS Code Denied Permission unlink 'usr/local/bin/code'

Viewed 44670

I can add the "shell command install 'code' command". Testing it works, but if i close out of the VS Code or after a couple of hours of adding the command it doesn't work. Terminal says "zsh: command not found: code" and on VS when click on the "shell command install code command" has a "EACCES: permission denied, unlink 'usr/local/bin/code' " pop up. How should i go about this? I'm using a macbook 2020 if that matters

9 Answers

Uninstall the code command from PATH in VS Code and reinstall it. Open the command palette in VS Code using cmd + shift + p. Search "uninstall 'code'" and select the first option to uninstall. Once uninstalled, "install 'code'" for installing. That should fix it.

This happened to me on Macbook Pro M1 Chip. Basically follow this:

Simply uninstall the code command from PATH in vscode and reinstalled. i.e open the command pallete, search "uninstall 'code'" and select the first option to uninstall. Do same for installing too. That should fix it.

Found this solution on github

Try run:

sudo chown -R yourUsername /usr/local/bin

This command solves user just for copy paste.

sudo chown -R $USER /usr/local/bin

From a sample size of me and three friends, this is a common problem on M1 MacBooks and Mac Minis. Running the command:

sudo chown -R yourUsername /usr/local/bin

This resolved the VS issue for me and allowed me to install npm packages globally.

For macOS:

  1. Try uninstalling and reinstalling. (command + shift + p) >shell Command: Uninstall 'code' command from Path

  2. append the following to your ~/.bash_profile file (~/.zshrc in case you use zsh).

    code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
    

For Mac I have run below steps in my terminal and it resolve my issue. you can also Try:

  1. Open terminal.
sudo chown -R your_user_name /usr/local/bin
  1. Open visual studio code.
  2. use keybord command + shift + p
  3. Type the bellow command. install 'code' Vs Code
  4. For test go to terminal and run code .

I was getting same error to Install on Windows 11:

  • Just deleted folder C:\Users\my-username\AppData\Local\Programs\Microsoft VS Code\bin

  • Also removed VS Code from environment variables

Installed successfully!

for any mac users, you can try

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

That should help. It's important to note that you should be careful using sudo, since you can do a lot of damage in files and folders with it. But in the most dire instances, you should use it, similar to using any kind of --force commands, you should not use it often.

Related