Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch VS Code from WSL Bash

Tags:

I have the Creators update installed. WSL is operational. I can execute most .exe files by simply calling notepad.exe But when it comes to VS Code.... I can't use the default code command or call code.exe... I have also tried code and code.cmd. Why doesn't VS Code execute like other programs? And is there a way to enable the code command?

EDIT: I now get these errors:

me@mypc:/mnt/c/Users/me/Documents/project_folder$ code . /mnt/c/Program Files (x86)/Microsoft VS Code/bin/code: line 7: realpath: comma nd not found /mnt/c/Program Files (x86)/Microsoft VS Code/bin/code: line 14: ./Code.exe: No such file or directory

like image 321
Auzy Avatar asked Apr 26 '17 16:04

Auzy


People also ask

How do I launch VS Code from WSL?

Alternatively, you can open a Remote WSL window directly from VS Code: Start VS Code. Press F1, select Remote-WSL: New Window for the default distro or Remote-WSL: New Window using Distro for a specific distro. Use the File menu to open your folder.

How do I launch VS Code as root?

sudo code . It is recommended to start vscode as a normal user. To run as root, you must specify an alternate user data directory with the --user-data-dir argument.

How do I open VS Code in terminal?

One way of opening your terminal is hitting the command button and the spacebar at the same time. This opens spotlight search. From here, you can type "terminal". Once your terminal is open, you can open VS Code from it by typing $ code .


1 Answers

The Creators update did install the interop functionality. However, it seems you need to install realpath in WSL in order for the path to be recognized. I'm not sure why this is the case but running sudo apt-get install realpath fixed it for me!

EDIT: After updating to the Fall Creators Update launching VSCode from WSL works out of the box 🎉

like image 89
Auzy Avatar answered Sep 25 '22 12:09

Auzy