Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl --install : A specified logon session does not exist. It may already have been terminated. #9521

Open
1 of 2 tasks
JWray27 opened this issue Jan 23, 2023 · 34 comments
Open
1 of 2 tasks

Comments

@JWray27
Copy link

JWray27 commented Jan 23, 2023

Version

Microsoft Windows [Version 10.0.22621.1105]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

No response

Distro Version

No response

Other Software

No response

Repro Steps

Initial install. Downloaded wsl from MS store. Stared admin command shell. Typed wsl --install.
wsl install virtual machine support, and then terminated with the message:
A specified logon session does not exist. It may already have been terminated.

Attempting to rerun wsl now just give the error about logon session:

C:\Windows\System32>wsl --install
Installing: Windows Subsystem for Linux
A specified logon session does not exist. It may already have been terminated.

Expected Behavior

Expecting to successfully install wsl

Actual Behavior

Got the error message above

Diagnostic Logs

No response

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 24, 2023

/logs

@ghost
Copy link

ghost commented Jan 24, 2023

Hello! Could you please provide more logs to help us better diagnose your issue?

To collect WSL logs, download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
Set-ExecutionPolicy Bypass -Scope Process -Force
.\collect-wsl-logs.ps1

The scipt will output the path of the log file once done.

Once completed please upload the output files to this Github issue.

Click here for more info on logging

Thank you!

@JWray27
Copy link
Author

JWray27 commented Jan 24, 2023

@ghost ghost removed the needs-author-feedback label Jan 24, 2023
@OneBlue
Copy link
Collaborator

OneBlue commented Jan 25, 2023

Thanks @JWray27.

Which context are you running the command from ? Are you logged in to the machine interactively, or via RDP / SSH / PSRemote ?

Also, which user account are you running the command from ?

@JWray27
Copy link
Author

JWray27 commented Jan 25, 2023

Interactively. In a command prompt launched from my (unprivileged) local account using "Run As Administrator".

@ghost ghost removed the needs-author-feedback label Jan 25, 2023
@michael-logan
Copy link

Following this issue too.

@zxcvxzcv-johndoe
Copy link

I got the same error message too using my non local administrator Windows account when I used "Run as Administrator".

For me workaround was to log into Windows with local admin account, open Powershell "Run as Admin" -> "wsl --install"

@saonideb
Copy link

The issue occurs even when using local admin rights

@atomicparade
Copy link

I was unable to install WSL or Ubuntu from PowerShell.

However, I was able to install WSL and Ubuntu from the Microsoft Store, restart my computer, and then launch Ubuntu from Windows Terminal to finish the setup process. (Without restarting, I got an error message when trying to start Ubuntu.)

@TheophileKikleo
Copy link

Hi, I had the same issue, could not install wsl whether with powershell, cdm, ran as admin or not, I figured out (when uninstalling everything) that I could turn on both 'Virtual Machine Plateform' and 'Windows Subsystem for Linux' in Settings >Apps > Apps and features > more windows. Then, without having to run PowerShell as admin, running wsl --install -d Ubuntu and wsl --set-default-version 2, made everything work right!

@marcelomgarcia
Copy link

I have the same problem when trying to install WSL on my Windows

Edition	Windows 11 Home
Version	21H2
Installed on	‎2/‎24/‎2023
OS build	22000.1574
Serial number	PF3ZFMB4
Experience	Windows Feature Experience Pack 1000.22000.1574.0

I'm using a user account instead of the main (administrator) account. I tried both, by entering the PIN to elevate my privileges and opening a Powershell as administrator, and the result was the same:

PS C:\Users\marce> wsl --install -d Ubuntu-22.04
Installing: Windows Subsystem for Linux
A specified logon session does not exist. It may already have been terminated.

The suggestion of TheophileKikleo worked for me: by adding a new feature to Windows. After installing WSL, I was able to install Ubuntu.

PS C:\Users\Marcelo Garcia> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-22.04    Running         2
PS C:\Users\Marcelo Garcia>

@svenMolhuijsen
Copy link

I have the same issue while installing WSA with local admin rights.

@iannuz
Copy link

iannuz commented Feb 27, 2023

Same issue using WSL with local admin rights

@AlvaroMartinezQ
Copy link

AlvaroMartinezQ commented Mar 1, 2023

I had the same problem:

PS C:\...>wsl --install -d Ubuntu-22.04
The requested operation requires elevation.
Installing: Windows Subsystem for Linux
A specified logon session does not exist. It may already have been terminated.

After looking around I found that Virtual Machine Platform is needed to be activated to run it. You have to enable this in the 'Turn windows features on and off'. But turns out I also had to enable HyperV (not so sure why) on that same panel for the above command to work.

After a restart and installation of the required packages by the system, I could successfully run:

PS C:\...> wsl --install -d Ubuntu-22.04

After that the Ubuntu CLI opened for user & password setup.
The command above was executed without admin privileges. Try to specify the version with the -d flag on your install.

PD: I also had to install the Linux kernel update manually as seen in this post.

@gojimmypi
Copy link

I encountered this same problem on Windows 11.

@benjaminbixby
Copy link

Windows 11 Pro 22H2 22621.1413 same issue

@Al-Cid
Copy link

Al-Cid commented Mar 20, 2023

Hi JWray27

I was also puzzled by the borked installation of wsl on a new Windows 11 system. There is no mention of the follow procedure in the Microsoft wsl installation guides - and I think it should be because this is what caused my install to fail in the same manner as yours:
"In the Windows search bar, type 'features' to bring up the Turn Windows Features on and off dialog. Scroll down and check Windows Subsystem for Linux. Select OK and you will be prompted to restart Windows."

Mine was not checked - perhaps this it checked by default (i would think so, though). However with this checked and after a restart, the wsl --installl command in powershell (as admin) exited cleanly.

Best of luck.
Al-Cid

@johnnymatt
Copy link

wsl --update, then wsl --install -d Ubuntu

@speed65
Copy link

speed65 commented Aug 10, 2023

It appears that the developers may have overlooked adding the /norestart flag to commands similar to those listed below when they created the new wsl --install command/script. I assume the new command operates similarly to the old method of installing WSL, as found here.

It seems that the /norestart flag was possibly missed or forgotten in the new command's implementation and it should have read something like this:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

This is speculative. After running the wsl --install command, I encountered the same error mentioned above. However, after rebooting my machine and installing the pending updates, WSL resumed. I then entered my username and password, and now WSL2 is installed and running.

My advice is to reboot after running wsl --install, as this seems to resolve the issue.

Cheers!
YMMV

@keytrap-x86
Copy link

keytrap-x86 commented Aug 31, 2023

What worked for me was to install WSL2 frome the Windows Store : https://aka.ms/wslstore

@benjamin-rousseau-shift
Copy link

benjamin-rousseau-shift commented Sep 7, 2023

What worked for me was :

on non-admin user, with powershell.exe run as admin

  • tried wsl --install (didn't work)
  • installed WSL through windows feature (it installed and rebooted)
  • tried wsl --install (was showing distros, but could not install them with wsl --install -d distroname)
  • tried wsl --update (didn't work)

I switched user then logged on the admin session :

  • launched wsl --update in powershell

Switched back to non-admin user with powershell.exe run as non-admin :

  • launched wsl --install

and it worked.
I probably would have lost less time if I directly logged on the admin session but I did not know I would face this lol.

@qhaas
Copy link

qhaas commented Sep 17, 2023

Same issue, possibly related to locking my screen while the install was ongoing. A reboot and rerunning the command wsl --install from an admin powershell terminal didn't clear it. I'm using Windows 11 22H2.

UPDATE: I had to be logged in as an admin, not just using a powershell with admin, got it working

@Erich-Chen
Copy link

Encountered the same issue on a fresh installed Windows 11 22H2.

Installing WSL in Windows Store seems the solution to me:

https://www.microsoft.com/store/productid/9P9TQF7MRM4R

@mrt181
Copy link

mrt181 commented Oct 19, 2023

'Virtual Machine Plateform' and 'Windows Subsystem for Linux' were already active but I had to also check Hyper-V in 'Windows feature'. After a reboot I was able to use wsl 2 and install a distro.

@FloHu
Copy link

FloHu commented Nov 15, 2023

I had the same issue and this thread helped me to almost solve the problem but with a bit of a twist: After activating WSL in Windows features and rebooting I could not install wsl as an administrator (also wsl --update did not work) and also the error messages were just generic. Only when I then tried to install as a user did I get an error message pointing me to a site (https://aka.ms/wsl2kernel) where I could download a necessary kernel update. After that it worked. I noticed that that site is just the one for manually installing WSL2 and it seems to contain the steps outlined in this thread as shell commands so perhaps that would have been faster.

@joshi-harish
Copy link

I had the same issue and this thread helped me to almost solve the problem but with a bit of a twist: After activating WSL in Windows features and rebooting I could not install wsl as an administrator (also wsl --update did not work) and also the error messages were just generic. Only when I then tried to install as a user did I get an error message pointing me to a site (https://aka.ms/wsl2kernel) where I could download a necessary kernel update. After that it worked. I noticed that that site is just the one for manually installing WSL2 and it seems to contain the steps outlined in this thread as shell commands so perhaps that would have been faster.

This worked for me. Thanks.

@Radhwen-1919
Copy link

Bonjour, j'ai eu le même problème, je n'ai pas pu installer wsl, que ce soit avec PowerShell, Cdm, exécuté en tant qu'administrateur ou non, j'ai compris (en désinstallant tout) que je pouvais activer à la fois « Plateforme de machine virtuelle » et « Sous-système Windows pour Linux ». dans Paramètres > Applications > Applications et fonctionnalités > plus de fenêtres. Ensuite, sans avoir à exécuter PowerShell en tant qu'administrateur, en exécutant wsl --install -d Ubuntuet wsl --set-default-version 2, tout a fonctionné correctement !

B

Hi, I had the same issue, could not install wsl whether with powershell, cdm, ran as admin or not, I figured out (when uninstalling everything) that I could turn on both 'Virtual Machine Plateform' and 'Windows Subsystem for Linux' in Settings >Apps > Apps and features > more windows. Then, without having to run PowerShell as admin, running wsl --install -d Ubuntu and wsl --set-default-version 2, made everything work right!

Hi @TheophileKikleo,
you can send me your mail ! I need to contact you about WSL please.
Thank you

@elpezganzo
Copy link

The issue is because you do not have enabled the WSL in Control Panel\All Control Panel Items\Programs and Features\Turn Windows Features on or off. Check the feature "Windows Subsystem for Linux", and restart you machine.

@karman-docker
Copy link

karman-docker commented Apr 29, 2024

encountered the same issue. I am logged in as a non-admin user. Windows Subsystem for Linux and Hyper-V features are enabled and machine was rebooted after they were enabled.

I opened cmd terminal with 'Run as administrator' and tried to run 'wsl --update'
Installing: Windows Subsystem for Linux
A specified logon session does not exist. It may already have been terminated.

I am on Windows 11 Build 22631.3447

@karman-docker
Copy link

Figured out the above error happens only if you are not a local user. At least in my case, I had logged in as a domain user.

@zeekus
Copy link

zeekus commented May 7, 2024

I got a replacement laptop for work and had the similar error.

The Problem
When you tried to install WSL using the command wsl --install, you encountered the following error:

PS C:\...>wsl --install 
Installing: Windows Subsystem for Linux
A specified logon session does not exist. It may already have been terminated. 

The Cause
The error message suggests that the installation process was unable to access a required logon session.

The Solution:

Log in to your computer using an administrative account.
Then, log back in using your regular, unprivileged user account.

This allowed Windows to create the missing profile information that was being requested.

Afterwards, I was able to run theseommands successfully as a regular user using admin elevation.

wsl --install
wsl --set-default-version 2
wsl --update
wsl --list --online
wsl --install -d Debian

@vaundrex
Copy link

I just had the same issue trying wsl --install as a standard user with a termianl running as administrator. Resolved using tip from zxcvxzcv-johndoe. Login as local admin user, run wsl --install, then log back in as standard user and run wsl --install.

@natewaddoups
Copy link

In my case, the solution was to check the "windows subsystem for linux" checkbox in the "Turn Windows Features On Or Off" dialog box.

Note that it was not necessary (in my case) to log on as the administrator. I only logged on with my regular user account, and then elevated to admin when prompted.

Someone at Microsoft apparently believes that installing WSL and enabling WSL are entirely unrelated concepts, and it wouldn't make sense to enable WSL while installing WSL.

And someone at Microsoft also believes that the error message in the title of this thread is an acceptable way to (attempt to) inform the customer that they need to enable WSL before installing WSL.

It's been this way for over a year, so I'm guessing there's a ticket somewhere inside Microsoft with properties like:
Resolution: won't fix
Reason: not a regression

@jgunstone
Copy link

I had the same issue with wsl installation on a machine that is managed by an admin team that I do have an administrator p/w for.
I had to change the "Turn Windows Features on of off" as follows

image

restart my machine

ask the IT adminstrator to login again as described here: #9521 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests