Khalil's Blog

Research | ML | Software Engineering

28 Feb 2019

VSCode Shell Commands not retaining install status in $PATH after restart

After you download VSCode and add it to your PATH, you may stumble upon a problem where you cannot launch VSCode from the command line or Terminal — it’s as if something modifies your system PATH and takes out the VSCode entry.

This problem is notoriously annoying. But fret not, there’s a simple solution (for MacOS) users. Matan Gover responded to an GitHub issue related to the problem as follows:

I was having the same problem, but unlike @benday, I was running VS Code from /Applications (not from ~/Downloads). Turns out I still had the quarantine attribute set on VS Code – probably because I had moved it from ~/Downloads to /Applications using mv instead of Finder. Only moving it using Finder removes the quarantine attribute.

To fix the issue, I followed the instructions in #48124 (comment) and ran:

xattr -dr /Applications/Visual\ Studio\

IMO since this seems to cause confusion, VS Code should show a warning if “Shell Command: Install ‘code’ command in PATH” is invoked when running from a read-only file system, as in Squirrel/Squirrel.Mac#186. Even better would be to offer the user to fix it for them.

I have tested the proposed solution and it works! If you’re also having a similar problem with MacDown’s macdown command or PyCharm’s charm command, you now know what to do.