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

Using command ‘wsl’, there's no response. #10866

Open
1 of 2 tasks
Ethan-Chen-plus opened this issue Dec 2, 2023 · 33 comments
Open
1 of 2 tasks

Using command ‘wsl’, there's no response. #10866

Ethan-Chen-plus opened this issue Dec 2, 2023 · 33 comments

Comments

@Ethan-Chen-plus
Copy link

Ethan-Chen-plus commented Dec 2, 2023

Windows Version

10.0.25977.1000

WSL Version

0.0.0.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

No response

Distro Version

Ubuntu 1804

Other Software

'wsl' works well before, and I enjoy it. However, these days I can't open it.

Repro Steps

just using command wsl.

Expected Behavior

it should come into the ‘/home/kewei’ and show dedtails.

Actual Behavior

image

image

Diagnostic Logs

No response

the log file as the attachment:
WslLogs-2023-12-02_22-25-54.zip

I have tried these, but none of them works:

1. go to services.msc, make sure service LxssManager is running, if it is running already, restart it,after turn it on I can use wsl immediately.
2. Get-Service LxssManager | Restart-Service
Copy link

github-actions bot commented Dec 2, 2023

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 4, 2023

/dump

@Ethan-Chen-plus
Copy link
Author

Ethan-Chen-plus commented Dec 5, 2023

image

I make my wsl run for 5 minutes with no response for Log collection is running. Please reproduce the problem and press any key to save the logs.

However File size too big: 25 MB are allowed, 53 MB were attempted to upload.
So I upload to repo:https://github.com/Ethan-Chen-plus/WslLogs/blob/main/WslLogs-2023-12-05_09-18-19.zip

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 5, 2023

Thank you @Ethan-Chen-plus. Looking at the dump it looks like things are stuck on the Linux side.

Let's see what's happening inside the VM. Can you please:

  • Reproduce the issue
  • Open a debug shell via: wsl.exe --debug-shell
  • Paste the content of this script inside the debug shell
  • Share the output on this issue
  • The script will also output the path to a folder where it wrote some logs files, please share that folder here as well

This should help us understand where things are stuck

@DoctorWho8
Copy link

Thank you @Ethan-Chen-plus. Looking at the dump it looks like things are stuck on the Linux side.

Let's see what's happening inside the VM. Can you please:

  • Reproduce the issue
  • Open a debug shell via: wsl.exe --debug-shell
  • Paste the content of this script inside the debug shell
  • Share the output on this issue
  • The script will also output the path to a folder where it wrote some logs files, please share that folder here as well

This should help us understand where things are stuck

Let's suppose I need to do all of that to debug a potential problem within the distribution which currently isn't available from the Microsoft Store. How therefore do I go about invoking the debug shell? This was returned from a regular Powershell routine:
"PS C:\Users\GCL\Desktop> wsl --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND"
And this was returned from an Administration level one:
"PS C:\Users\GCL\Desktop> cd ..
PS C:\Users\GCL> wsl --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND"

The strange part I was able to invoke the debug shell earlier, but wasn't able to paste the shell script described there.

@Ethan-Chen-plus
Copy link
Author

Ethan-Chen-plus commented Dec 6, 2023

I used command wsl.exe --debug-shell and pasted the script

image
image
image

root@DESKTOP-3JRQ3HI [ ~ ]# set -ue

if [ $(whoami) != "root" ]; then
t --system)" script must be run as root in the system distro (via wsl.exe -u root
  exit 1
fi

ts=$(date +%F_%H-%M-%S)
target="/mnt/c/wsl-init-dump-$ts"

mkdir -p "$target"

tdnf install -y gdb

bash -c "cd $target && gcore -a \$(pgrep init)"

stack_log="$target/stacks.txt"
fd_log="$target/fd.txt"
for pid in $(pgrep init); do
  echo -e "\nProcess: $pid" >> "$stack_log"
  echo -e "\nProcess: $pid" >> "$fd_log"
  for tid in $(ls "/proc/$pid/task" || true); do
    echo "tid: $tid" >> "$stack_log"
echo "Logs and dumps written in $target"t"rueck_log" || true
Loaded plugin: tdnfrepogpgcheck
Refreshing metadata for: 'CBL-Mariner Official Extras 2.0 x86_64'
Refreshing metadata for: 'CBL-Mariner Official Microsoft 2.0 x86_64'
Refreshing metadata for: 'CBL-Mariner Official Base 2.0 x86_64'
mariner-official-base                  1285195 100%
Installing:
python3-libs     x86_64       3.9.14-8.cm2     mariner-official-base  30.73M    10.41M
python3          x86_64       3.9.14-8.cm2     mariner-official-base  45.46k    35.81k
mpfr             x86_64       4.1.0-2.cm2      mariner-official-base   2.72M     1.44M
zstd             x86_64       1.5.0-1.cm2      mariner-official-base 1009.51k  424.70k
elfutils-default-yama-scope noarch       0.186-1.cm2      mariner-official-base   1.77k    33.03k
zstd-devel       x86_64       1.5.0-1.cm2      mariner-official-base 171.69k    50.60k
xz-devel         x86_64       5.2.5-1.cm2      mariner-official-base 329.15k   100.59k
elfutils-libelf-devel x86_64       0.186-1.cm2      mariner-official-base  32.98k    39.95k
elfutils         x86_64       0.186-1.cm2      mariner-official-base   3.32M     1.19M
elfutils-devel   x86_64       0.186-1.cm2      mariner-official-base 190.29k    87.38k
gdb              x86_64       11.2-2.cm2       mariner-official-base  11.57M     4.97M

Total installed size:  50.08M
Total download size:  18.77M
python3-libs                          10919586 100%
python3                                  36668 100%
mpfr                                   1510228 100%
zstd                                    434888 100%
elfutils-default-yama-scope              33821 100%
zstd-devel                               51815 100%
xz-devel                                103009 100%
elfutils-libelf-devel                    40906 100%
elfutils                               1248214 100%
elfutils-devel                           89476 100%
gdb                                    5210872 100%
Testing transaction
Running transaction
Installing/Updating: python3-3.9.14-8.cm2.x86_64
Installing/Updating: python3-libs-3.9.14-8.cm2.x86_64
Installing/Updating: elfutils-libelf-devel-0.186-1.cm2.x86_64
Installing/Updating: xz-devel-5.2.5-1.cm2.x86_64
Installing/Updating: elfutils-default-yama-scope-0.186-1.cm2.noarch
Installing/Updating: zstd-1.5.0-1.cm2.x86_64
Installing/Updating: zstd-devel-1.5.0-1.cm2.x86_64
Installing/Updating: elfutils-0.186-1.cm2.x86_64
Installing/Updating: elfutils-devel-0.186-1.cm2.x86_64
Installing/Updating: mpfr-4.1.0-2.cm2.x86_64
Installing/Updating: gdb-11.2-2.cm2.x86_64
[New LWP 146]
0x00000000003e485d in ?? ()
Saved corefile core.1
[Inferior 1 (process 1) detached]
0x00000000003e485d in ?? ()
warning: target file /proc/152/cmdline contained unexpected null characters
Saved corefile core.152
[Inferior 1 (process 152) detached]
[New LWP 161]
0x00000000003e485d in ?? ()
warning: target file /proc/160/cmdline contained unexpected null characters
Saved corefile core.160
[Inferior 1 (process 160) detached]
0x00000000003e485d in ?? ()
Saved corefile core.162
[Inferior 1 (process 162) detached]
warning: Target and debugger are in different PID namespaces; thread lists and other data are likely unreliable.  Connect to gdbserver inside the container.
0x00000000003e485d in ?? ()
Saved corefile core.163
[Inferior 1 (process 163) detached]
Logs and dumps written in /mnt/c/wsl-init-dump-2023-12-06_15-16-04
root@DESKTOP-3JRQ3HI [ ~ ]#

image

But how to copy and open this folder?

@DoctorWho8
Copy link

I agree with @Ethan-Chen-plus here. What is also needed is that of feedback from the author. No not yourself, @Ethan-Chen-plus I mean any of the folks from Microsoft who happens to be involved here.

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 7, 2023

Thank you @Ethan-Chen-plus. /mnt/c maps to your C: drive in Windows so you should be able to just open the windows explorer from the start menu and grab the files from there.

@DoctorWho8
Copy link

@OneBlue I just repeated @Ethan-Chen-plus did and found the folder it created. However, since the VM is running properly, I did in fact see nothing there. Is this normal for a properly working image?

@Ethan-Chen-plus
Copy link
Author

However I can't find it in my C: drive. I looked into the script.
I found that it just make a directory:
1701916537690
image

And since there is no '/mnt/c' before executing this script, I thought that's why I couldn't found it in 'C:'.

I think we should mount 'C:' to '/mnt/c' in wsl debugger before we execute the script. But how to mount?

@DoctorWho8
Copy link

@Ethan-Chen-plus It did for my run.

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 11, 2023

Oh I see what's happening @Ethan-Chen-plus. This is most likely because things get stuck before /mnt/c even gets mounted.

Let's try another approach: Can you run this script instead ? It will output everything on stdout so there should be no need to access /mnt/c.

@Ethan-Chen-plus
Copy link
Author

The output can be seen in the detachment.
log.txt

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 13, 2023

Thank you @Ethan-Chen-plus. With these logs we found a bug that triggers the hang you're seeing.

Although that bug only explains half of your symptoms. Most likely something in your distro is causing init to crash.

Can you try to add:


[wsl2]
safeMode=true

In %USERPROFILE%/.wslconfig

And see if the distribution starts that way ?
Also is systemd enabled inside your distribution ?

@Ethan-Chen-plus
Copy link
Author

I added it as below.But Still it has no response.
image
image

@benhillis
Copy link
Member

@Ethan-Chen-plus
Copy link
Author

@benhillis Hi, benhillis! Thanks for your work. But how can I get this update? After updating my windows11, could I get this new feature?

@OneBlue
Copy link
Collaborator

OneBlue commented Dec 21, 2023

@Ethan-Chen-plus: You can get it by running: wsl.exe --install --pre-release

@Ethan-Chen-plus
Copy link
Author

@OneBlue However this can't work.This is just printing some command usage information about wsl.exe in the console.

PS C:\Users\25122> wsl.exe --install --pre-release

Copyright (c) Microsoft Corporation. All rights reserved.
For privacy information about this product, please visit https://aka.ms/privacy.

Usage: wsl.exe [Parameters] [Options...] [Command Line]

Parameters for running Linux binaries:

   If no command line is provided, wsl.exe will launch the default shell.

   --exec, -e <CommandLine>
       Execute the specified command without using the default Linux shell.

   --shell-type <standard|login|none>
       Execute the specified command with the provided shell type.

   --
       Pass the remaining command line as-is.

Options:
   --cd <Directory>
       Set the specified directory as the current working directory.
       If using ~, it will use the Linux user's home path. If the path starts with
       /, it will be interpreted as an absolute Linux path.
       Otherwise, the value must be an absolute Windows path.

   --distribution, -d <Distro>
       Run the specified distribution.

   --user, -u <UserName>
       Run as the specified user.

   --system
       Start a shell for the system distribution.

Parameters for managing Windows Subsystem for Linux:

   --help
       Display usage information.

   --debug-shell
       Open a WSL2 debug shell for diagnostic purposes.

   --install [Distribution] [Options...]
       Install a distribution of Windows Subsystem for Linux.
       For a list of valid distributions, use "wsl.exe --list --online".

       Options:
           --no-launch, -n
               Do not launch the distribution after installation.

           --web-download
               Download the distribution from the internet instead of the Microsoft Store.

           --no-distribution
               Only install the required optional components, without installing the distribution.

   --manage <Distro> <Options...>
       Change distribution-specific options.

       Options:
           --set-sparse, -s <true|false>
               Set the VHDX of the distribution to be sparse, allowing for automatic disk space reclamation.

   --mount <Disk>
       Attach and mount a physical or virtual disk in all WSL 2 distributions.

       Options:
           --vhd
               Specify <Disk> as a reference to a virtual hard disk.

           --bare
               Attach the disk to WSL2 but do not mount it.

           --name <Name>
               Mount the disk with a custom name for the mount point.

           --type <Type>
               The file system to use when mounting the disk (if not specified, defaults to ext4).

           --options <Options>
               Additional mount options.

           --partition <Index>
               The index of the partition to mount (defaults to the entire disk if not specified).

   --set-default-version <Version>
       Change the default installation version for new distributions.

   --shutdown
       Terminate all running distributions and the WSL 2 lightweight utility VM immediately.

   --status
       Display the status of Windows Subsystem for Linux.

   --unmount [Disk]
       Unmount and detach disks from all WSL 2 distributions.
       If called without parameters, unmount and detach all disks.

   --update
       Update the packages in Windows Subsystem for Linux.

       Options:
           --pre-release
               Download pre-release versions if available.

   --version, -v
       Display version information.

Parameters for managing distributions within Windows Subsystem for Linux:

   --export <Distro> <FileName> [Options]
       Export the distribution to a tar file.
       The filename can be "-" for stdout.

       Options:
           --vhd
               Specify that the distribution should be exported as a .vhdx file.

   --import <Distro> <InstallLocation> <FileName> [Options]
       Import the specified tar file as a new distribution.
       The filename can be "-" for stdin.

       Options:
           --version <Version>
               Specify the version to use for the new distribution.

           --vhd
               Specify that the provided file is a .vhdx file instead of a tar file.
               This operation creates a copy of the .vhdx file at the specified installation location.

   --import-in-place <Distro> <FileName>
       Import the specified .vhdx file as a new distribution.
       The format of this virtual hard disk must be set to ext4.

   --list, -l [Options]
       List distributions.

       Options:
           --all
               List all distributions, including those currently being installed or uninstalled.

           --running
               List only currently running distributions.

           --quiet, -q
               Display only the distribution names.

           --verbose, -v
               Display detailed information about the distributions.

           --online, -o
               Display a list of available distributions for installation using "wsl --install".

   --set-default, -s <Distro>
       Set the distribution as the default.

   --set-version <Distro> <Version>
       Change the version of the specified distribution.

   --terminate, -t <Distro>
       Terminate the specified distribution.

   --unregister <Distro>
       Unregister the distribution and delete the root filesystem.

@mosullivan93
Copy link

@Ethan-Chen-plus Try wsl --update --pre-release because you already have wsl installed.

(I'm not affiliated with the WSL team, just happened upon this from reading release notes and thought I'd try to help while the MS staff are away for the holidays).

@Ethan-Chen-plus
Copy link
Author

@mosullivan93 Thank you, this works.However there's another issue occurred

PS C:\Users\25122> wsl --update --pre-release
Checking for updates.
Updating Windows Subsystem for Linux to version: 2.0.15.
(Here are some progress bars displayed.)
Checking for updates.
Updating Windows Subsystem for Linux to version: 2.0.15.

PS C:\WINDOWS\system32> wsl
wsl: Safe mode is enabled - many features will be disabled
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED

@benhillis
Copy link
Member

@Ethan-Chen-plus
Copy link
Author

@benhillis Thanks. But there're still errors:

PS C:\WINDOWS\system32> wsl --update --pre-release
Checking for updates.
Updating Windows Subsystem for Linux to version: 2.1.0.
PS C:\WINDOWS\system32> wsl
wsl: Secure mode is enabled - many features will be disabled
Critical error
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
PS C:\WINDOWS\system32>

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 9, 2024

Thank you @Ethan-Chen-plus. This is interesting. Can you collect updated /logs with 2.1.0 ?

@zhongTao99
Copy link

I have the same problem as this issue. I have upgraded the version to 2.1.0.0, but it still freezes when running.I have sent the log by email and hope to get a reply as soon as possible

@Ethan-Chen-plus
Copy link
Author

@OneBlue Thank you for reopening the issue, however there was a promble: debug-shell couldn't be used now:

PS C:\Users\25122> wsl.exe --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND

So I can't collect the logs.

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 12, 2024

Thanks @Ethan-Chen-plus. The debug shell is only available if WSL is already running. Can you try to start wsl first ?

@Ethan-Chen-plus
Copy link
Author

@OneBlue Sorry but I can't start wsl first as below shown:

PS C:\Users\25122> wsl
wsl: Safe mode is enabled - many features will be disabled
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
PS C:\Users\25122> wsl
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
PS C:\Users\25122> wsl
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
PS C:\Users\25122> wsl.exe --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND

@OneBlue
Copy link
Collaborator

OneBlue commented Jan 19, 2024

@Ethan-Chen-plus: Interesting, it looks like wsl is just failing to start.

Can you collect regular /logs in this case ?

@Ethan-Chen-plus
Copy link
Author

Ethan-Chen-plus commented Jan 20, 2024

@OneBlue The logs:
WslLogs-2024-01-20_10-28-13.zip

Terminal1:

PS C:\WINDOWS\system32> Set-ExecutionPolicy Bypass -Scope Process -Force
PS C:\WINDOWS\system32> .\collect-wsl-logs.ps1

    Directory: C:\WINDOWS\system32


Operation completed successfully.
Operation completed successfully.
Operation completed successfully.
Operation completed successfully.
Log collection is running. Please reproduce the problem and press any key to save the logs.
Saving logs...
100%  [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]
Logs saved in: C:\WINDOWS\system32\WslLogs-2024-01-20_10-28-13.zip. Please attach that file to the GitHub issue.

At the same time I reproduced the error in Terminal2:

PS C:\Users\25122> wsl
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
PS C:\Users\25122> wsl
Catastrophic failure
Error code: Wsl/Service/CreateInstance/E_UNEXPECTED
PS C:\Users\25122> wsl.exe --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND
PS C:\Users\25122> wsl.exe --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND
PS C:\Users\25122> wsl.exe --debug-shell
The system cannot find the file specified.
Error code: Wsl/DebugShell/ERROR_FILE_NOT_FOUND

Hope the can help to find the reason.

@umangutkarsh
Copy link

umangutkarsh commented Jan 20, 2024

Hey, even I'm facing the same problem, wsl command, not showing any output. Also not abe to access the remote wsl window on vscode using esl extension. I have checked that everything including the wsl settings is enabled, and Vitualization is also enabled in BIOS settings.

Still not able to figure out. Also when running this command -> wsl --update --pre-release
I'm getting some errors, will share the error logs.

This is the Error i'm getting:
psh

Error logs:
wsl-install-logs.txt

VSCode extension not working, not opening remote wsl:
wsl

WSL enabled:
onoff

Powershell not giving any response on any wsl command:
ps

Stuck in this since days, still not getting what's wrong here.

Would be helpful if anyone finds a solution to this. Thanks for your time.

@Ethan-Chen-plus
Copy link
Author

@OneBlue Hi! 👋 Are you still here?

@boxqkrtm
Copy link

same issue but i fix with turn off ntfs compress
image

it can't change compress option but can be able to copy and remove old

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

8 participants