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

Failed to detect WSL2 instance #298

Closed
1 task done
jacky9813 opened this issue Sep 22, 2022 · 1 comment
Closed
1 task done

Failed to detect WSL2 instance #298

jacky9813 opened this issue Sep 22, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@jacky9813
Copy link

Windows version (build number):
Windows 10 Pro Version 21H2 (Build 19044.1889)

Linux distribution:
Debian Bullseye, upgraded from Debian Stretch from Microsoft Store

Kernel version:
5.10.16.3-microsoft-standard-WSL2

Genie version:
The output of the command is genie: not executing under WSL 2 - how did we get here?
The command sudo apt list | grep genie shows it's 2.4 amd64

Describe the bug
As the output of the version shows, genie is unable to detect that the environment is running WSL2.

Confirm that you are running inside the bottle:
Negative.

To Reproduce

  1. Follows the instruction and install systemd-genie.
  2. Shutdown the WSL2 with wsl.exe --shutdown
  3. Try Starting WSL2 with wsl.exe genie -s, the error occurs.

Expected behavior
Launches WSL2 with systemd and opens a shell prompt.

Screenshots
image

Additional context
Workaround:
Using command wsl.exe sudo touch /run/WSL ; genie -s

==================

The message appears to be generated genie: not executing under WSL 2 - how did we get here? in line 71 of file binsrc/genie/helpers.py
Here's a snippet of it:

    if not os.path.exists('/run/WSL'):
        if 'microsoft' not in os.uname():
            sys.exit("genie: not executing under WSL 2 - how did we get here?")

The function os.uname will return a structured named attributes.
Hence the checking the output of uname against 'microsoft' will never be True.

Thus I recommend using os.uname().release instead:

    if not os.path.exists('/run/WSL'):
        if 'microsoft' not in os.uname().release:
            sys.exit("genie: not executing under WSL 2 - how did we get here?")

I confirm that I have read the ENTIRE supplied readme file and checked for relevant information on the repository wiki before raising this issue, and that if the solution to this issue is found in either location, it will be closed without further comment:

  • Yes.
@jacky9813 jacky9813 added the bug Something isn't working label Sep 22, 2022
@cerebrate
Copy link
Member

schrödinbugs are the weirdest, inasmuch as this has been working elsewhere for some time despite the fact that it shouldn't.

🤷🏻‍♂️

Still, fixed in 2.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants