I’ve read previous questions on this topic but I’m still stuck: apologies if this is off-topic.
System info:
I have the following setup:
Hardware: AMD GPU
Windows 10
Julia v1.11.2 installed in Windows
VSCodium installed in Windows
WSL 2 with Ubuntu 22.04 LTS distro
Julia v1.11.3 installed in WSL
“code” and “codium” packages from apt installed in WSL
Problem:
I’m using WSL(2) for Julia programming, and want to set things up smoothly with VSCode. I have tried to install VSCode as a WSL-only gui application (as “code” and “codium”), but WSL insists that I use the Windows version with the WSL command prompt instead.
In the Windows version, I can easily set the terminal to work with WSL, but the REPL is just the Windows one. This means that I can’t use the nice quality-of-life features in VSCode (executing code blocks, plots in panes, etc). Obviously I can write scripts as text files and execute them in the command line, but this is much less convenient and I would like to use the IDE-like features in VSCode natively. Is there any way to work smoothly with WSL in VSCode yet?
My reason for wanting to use WSL for this (rather than simply the Windows version of Julia) is due to the lack of support for AMD GPUs in Julia on Windows
Well, I’ve been using VS Code in WSL 2 for several years now with the full IDE environment, so yes, it is possible.
I’m not sure I fully understand the issues you are encountering.
One point that may cause confusion is that VS Code is not installed directly into WSL. The standard procedure would be to download a Linux package into WSL 2 and install it.
Instead, in case of VS Code, download the Windows version of VS Code and install it in Windows. Next, to install VS Code on WSL 2, I open a WSL 2 window using PowerShell and select the Linux version that you’ve installed [in my case, Ubuntu], from the drop down menu.
Once you have a WSL 2 window open, type “code .” and VS Code for WSL 2 will be installed automatically. You’ll see some typical lines about unpacking and installing. After that the VS Code IDE will open and you’ll have access to all its features.
I’ve been using WSL2 as a dev environment since WSL1 days.
On WSL2, install Julia and make sure it’s in PATH. On the Windows side, install the Windows version of vscode. If you don’t have it already, install the WSL connection. Then run the command: “Connect to WSL” and you’ll be able to open up folders on your linux filesystem (a badge on the bottom left shows you are connected to WSL). Next, once connected to WSL, install the Julia extension to get syntax highlighting and autocomplete. That’s about it.
My workflow is slightly different. Usually I am in the terminal connected to WSL2 and type in code foldername which automatically launches the Windows vscode, connects to WSL, and opens the folder. This may not work if you install vscode in Linux – don’t do this. Only have it installed on the Windows side of things.
This is also my workflow, been using this since WSL1 as well. As others have said, don’t install VScode within the linux distro running in WSL. Install it on the windows side. And make sure you have the WSL extension installed. See also here (specifically step no. 2 under installation).