Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
594 views
in Technique[技术] by (71.8m points)

visual studio code - How to open VSCode from a Windows Linux Subsystem?

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...