wsl command doesn't have --set-version option in my powershell - powershell

I tried to install new version of WSL meant WSL2 according to the installation instructions documented by Microsoft but the wsl command doesn't have --set-version option in my PowerShell to complete instructions while the WSL Ubuntu 18.04 is already been installed. I ran PowerSell as administrator in my windows 10 build 1903. How can i fix this? any help will be appreciated.

Related

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.

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

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.

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 do I run win32-openssh through the powershell? (installed with install-package from chocolatey provider)

So I am just trying to convert to powershell from bash. I was trying to find a way to SSH my server, and found out I could install win32-openssh to do so.
I installed it by:
Installing chocolatey as packageprovider using:
install-packageprovider chocolatey
Then i installed win32-openssh with the command:
install-package win32-openssh
My problem is now, how do I run this program?
It installs the correct binaries etc. It will not add some PS cmdlets for the use off ssh inside PS.
It is all described on the package site:
This package performs the following operations that you normally have to hack at until you get what you want:
Install Appropriate Bitness for the version of Windows
Install to Program Files (malware protection and following advice of dev team)
Add SSH location to System PATH
Optionally install sshd windows service (Requires parameter - see below)
Optionally install sshd server "key based authentication" (Requires parameter - see below)
Cleanly uninstall all of the above (removing config files and server keys requires special switch - see below)
So you can run it from start menu, or by typing ssh.exe into a prompt.
You have Two Options I can think of.
Option 1 : Use bash on Windows 10. Bash comes bundled with Windows 10. You can just enable a Windows 10 feature for it. Setup bash on Windows 10. You'll never miss bash again even if you're on Windows. [Recommended Option]
Option 2 : Set up SSH on Powershell by installing a package like PoSH-SSH.
Steps :
Pre-requisite : PC running Windows 10. Open PowerShell in Admin mode.
Find-Module PoSH-SSH
type 'Y' for the prompts.
Install-Module Posh-SSH
type 'A' for the prompts.
Reference:
https://www.thomasmaurer.ch/2016/04/using-ssh-with-powershell/
There's not really a need for this. If you have git installed on your Windows machine, you can add it's usr/bin folder to you path. It has ssh and other Unix tools you can use just like in Bash in PowerShell or CMD.