EACCES: permission denied, unlink ‘/usr/local/bin/code’ typically error occurs in a Unix-like operating system (such as Linux or macOS) and suggests that your user account does not have the necessary permissions to delete or modify the Visual Studio Code.
How to fix it?
To fix the error, try running the command as a privileged user using this command: sudo rm /usr/local/bin/code. This should prompt you for your password and execute the rm command with elevated privileges.
To uninstall Visual Studio Code on macOS, you can try dragging the Visual Studio Code application from the Applications folder to the Trash.
You can run this command in your terminal: sudo rm -rf /Applications/Visual\ Studio\ Code.app. Close all instances of Visual Studio Code before running this command.
Alternatively, you can try changing the ownership or permissions of the file to allow you to remove it. This can be done with the chown and chmod commands, respectively. However, be careful when modifying file permissions, which can have security implications.
If there are permission issues with the /usr/local/bin directory, you can reset the permissions with:
sudo chown -R $(whoami) /usr/local/bin
This command changes the ownership of /usr/local/bin to the current user, potentially resolving permission issues.
You can also try this solution: Uninstall the code command from PATH in VSCode and reinstall it. Then, 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.
If you are not using Homebrew or a similar package manager, and you are trying to update or uninstall Visual Studio Code, ensure you are following the correct procedure for your installation method.