Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh - OSX - visual studio command line won't stick

which code
code not found

Selecting the Install 'code' command in Path option from the VSCode command palette only fixes the problem temporarily.

The code command works then, even when I restart the terminal.

However, when I restart my computer I am back to

code not found

I can see that code is at /usr/local/bin/code

/usr/local/bin is already in my path.

like image 622
Daniel Thompson Avatar asked Mar 28 '17 00:03

Daniel Thompson


1 Answers

Check that the symlink /usr/bin/local/code isn't pointing to a translocated version of the VSCode binary. Mine was.

$ ls -l /usr/local/bin/code
code -> /private/var/folders/hz/w...n/T/AppTranslocation/...

To fix

  1. Ensure your VSCode installation is not running in App Translocation. This can happen if you move the VSCode binary to /Applications by, for example, using an Alfred workflow. You must manually drag the binary in to the folder in Finder. (What a drag. Ha ha. But seriously, WTF Apple?)
  2. You can fix this by dragging your existing binary out to the Desktop then back to the Applications folder.
  3. Delete the broken symlink: sudo rm /usr/local/bin/code.
  4. Re-install the link using the command in VSCode ("Install 'code' command in PATH").
like image 128
John Noble Avatar answered Sep 21 '22 16:09

John Noble