I have VSCode installed on my host OS which is Windows 10 on which I have an Ubuntu Subsystem terminal (WSL) and I’m trying to open VSCode from whitin it with this command code .
The problem is that the output is Command 'code' not found
. How can I make this work?
Advertisement
Answer
First, try installing the Remote - WSL
extension in VSCode (or the meta Remote Development
extension pack, which includes the WSL work).
I doubt that’s your main problem, but it could help.
Next, try running code .
under PowerShell – Does that work? If not, then VSCode isn’t in the Windows path. Try reinstalling it — If it’s not in the path, some other associations may not be correctly installed either. I don’t recall if there’s an option during installation to add or not add it to the Windows path, but if so, it could be that it was deselected during installation.
If it does launch in Windows, then obviously it’s in the Windows path. By default, WSL appends the Windows path to the default path in Ubuntu during init. So (again, by default) code .
should work in WSL if it is working under PowerShell.
Check your $PATH
under Ubuntu (echo $PATH
). Is the …/Microsoft VS Code/bin
directory (wherever it is installed) in the path? If not, then WSL may not be doing its default append. Edit /etc/wsl.conf
under Ubuntu and look to see if there’s an [interop]
section, as in:
[interop] appendWindowsPath=false
If so, then change it to true
(or, delete it entirely) to allow WSL to add the Windows path. While it’s the default setting if missing, you might try adding it and setting it to true
(although that shouldn’t have any effect).
If that still doesn’t work, then check your startup scripts (e.g. .profile
, .bash_profile
, .bashrc
) to see if there are any modifications to the PATH
which could be causing this problem.