How can I open a New Ubuntu 20.04 shell (WSL2) in VSCode integrated terminal - visual-studio-code

On my machine I have installed the WSL2 on Windows 10 Pro and a Ubuntu 20.04 LTS distro. I am also using VSCode as editor for programming. I start VSCode in Windows (not in the WSL2 Ubuntu) and there is the possibility to create a new terminal using the profile "New Ubuntu-20.04 (Standard) (WSL)".
Image: Start New Ubuntu 20.04 (Standard) (WSL)
However, this doesn't work as it calls the command "wsl -d Ubuntu-20.04 (Standard)" thus interpreting "(Standard)" as a command to be executed in WSL. This obviously fails as there is no command "(Standard)".
Image: Error message starting the shell
How can I change this profile? Is that possible at all?
As a workaround I can create a new profile in my VSCode user settings and pass the correct argument to the "wsl" command. But then I still have the defective profile entry in the integrated terminal. But I just want to have working entries there.
thanks in advance
Lars

The April 2021 release of VS code fixed the issue.

Related

vscode inside WSL vs Windows

In tutorial requirement is install vscode in windows and install Remote Development extension pack. Why not just install in wsl?
I've install vscode to wsl. When I run code in wsl I get message:
To use Visual Studio Code with the Windows Subsystem for Linux, please install Visual Studio Code in Windows and uninstall the Linux version in WSL. You can then use the `code` command in a WSL terminal just as you would in a normal command prompt.
Do you want to continue anyway? [y/N]
To no longer see this prompt, start Visual Studio Code with the environment variable DONT_PROMPT_WSL_INSTALL defined.
Which cons of run vscode in wsl as opposed to run it in Windows?
The WSL extension splits VS Code into a “client-server” architecture, with the client (the user interface) running on your Windows machine and the server (your code, Git, plugins, etc) running "remotely" in your WSL distribution.
When VS Code is started in WSL, no shell startup scripts are run.
The extension runs commands and other extensions directly in WSL so you can edit files located in WSL or the mounted Windows filesystem (for example /mnt/c) without worrying about pathing issues, binary compatibility, or other cross-OS challenges.
(source: MSFT DOCUMENTATION)
This is the architectural choice of Windows and - personally speaking - I feel like it's a choice to avoid conflicts and redundancies.
When running the WSL extension, selecting the 'Extensions' tab will display a list of extensions split between your local machine and your WSL distribution.
Installing a local extension, like a theme, only needs to be installed once.
Some extensions, like the Python extension or anything that handles things like linting or debugging, must be installed separately on each WSL distribution. VS Code will display a warning icon ⚠, along with a green "Install in WSL" button, if you have an extension locally installed that is not installed on your WSL distribution.

Strange vscode issue in WSL

I've been trying to set up the vscode code . shortcut to work in WSL. Following the instructions from the vscode website, I reinstalled vscode in windows, reinstalled the Remote-Wsl extension, made sure it was in my System Path, and tried running code . in the WSL linux distro terminal. I get the message instructing me to install it on the windows side, and asking me if I want to continue. I hit yes, but it doesn't create the code server folder in my home directory. Typing code . again does the same thing.
Does anyone know why this may be?
This is the output text:
To use Visual Studio Code with the Windows Subsystem for Linux, please install Visual Studio Code in Windows and uninstall the Linux version in WSL. You can then use the code command in a WSL terminal just as you would in a normal command prompt.
Do you want to continue anyway? [y/N]
The error message isn't just pointing out that you need to install the Windows version, but it indicates that you have the Linux version installed in WSL and should remove it.
From that, it sounds like at some point you may have installed the Linux version of VSCode in WSL, and that one is taking priority. You'll need to uninstall it in order to run the Windows version of VSCode with the "Remote - WSL" extension.
You don't mention what distribution you are running, but if it is Ubuntu, try:
sudo apt remove code # or
sudo apt remove code-insiders
Also see the uninstall doc from Microsoft.

nvm and gulp found on Visual Code terminal but not on linux terminal

I have Ubuntu LTS 20.04 running on wsl2 in Windows, this way I'm able to compile my JS/React code and run my php server in linux and use windows to code using Visual Studio Code.
This is running great, but a strange thing is happening, I installed nvm and gulp through the Visual Studio Code terminal and if I use them on the terminal it works fine but not if I do it outside the terminal (using Windows terminal), it says not found for both gulp and nvm.
I assume VSCode is adding a few things to the PATH but I don't know what to do for them to be found by the windows terminal (outisde VSCode terminal). Screen below. On the left is the result of running nvm list inside VS Code terminal and on the right on Ubuntu terminal, which can't find.
I'm a bit confused by your question. It sounds like you're installing programs on Windows through the VSCode terminal, and then trying to run them on Windows but it's not working. But then your screenshot shows the WSL Ubuntu prompt failing to find the command. Assuming you want to run these under WSL, log in to WSL Ubuntu and run this:
find / -name nvm
If you actually want to use the Windows terminal to run the program, you'll have to find where it is installed in Windows and make sure that's in your %PATH% but this doesn't seem like it's what you're trying to do.
The correct answer was provided by the comment from MindSwipe.
On VSCODE terminal if I "echo $PATH" it has the nvm directory in it while the $PATH on WSL doesn't, I assume VSCODE alters its own terminal PATH when the tools are installed using it instead of the global WSL path.
I've changed the WSL path and it's now working, how can I present the bounty to MindSwipe ?

How to get my windows conda to recognize my ANTs installed in Ubuntu?

My conda environment that runs python code is on my Windows 10.
I installed ANTs successfully in my Ubuntu- Windows subsystem for Linux.
How do I get my Windows to recognize this now? How do I export the WSL path to my Windows path variable?
This is my WSL Ubuntu in my Windows 10 system, with Ants and N4BiasFieldCorrection
This is my conda environment in Windows 10 unable to find the installed ANTs
Please help.
I don't think you can do what you are asking at the moment. Ubuntu is installed as a separate sub-system in Windows and applications installed in that subsystem are not accessible in Windows. This might change soon but I don't think it's possible right now.
In my opinion, you have to create the conda environment in your WSL, then you can work with it from Windows using Visual Studio Code with Remote - WSL extension.

How to integrate Anaconda environment (Ubuntu Windows) with VS Code?

I installed VS Code 1.24 on Windows 10.
I installed Ubuntu 18.04 bash on Windows 10. On Ubuntu Windows, I installed Anaconda for Linux, then created a new environment my_env.
How can I configure VS Code to recognize my_env?
Thanks
A little bit late but if someone has the same question.
Execute ctrl + shift + p and look for Terminal: Select Default Shell there you can select if you want to execute windows shell or bash or git bash.
A second way is: go to File > Preferences > Settings there put this in user settings:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe"
Here the documentation