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

WSL2 might be supported now #64

Closed
AlekSi opened this issue Nov 22, 2024 · 21 comments
Closed

WSL2 might be supported now #64

AlekSi opened this issue Nov 22, 2024 · 21 comments
Milestone

Comments

@AlekSi
Copy link

AlekSi commented Nov 22, 2024

See actions/runner-images#10563 and https://github.com/vedantmgoyal9/setup-wsl2.

It would be nice to have it supported by this action.

@ssbarnea
Copy link

ssbarnea commented Nov 27, 2024

We are setting up custom runners but we still want to keep using the action, so it should be possible to configure the wsl version being used. What is worse is the the linked alternative setup-wsl2 action is not api compatible with current, basically it does not have any of the arguments supported by the current one.

@vedantmgoyal9
Copy link

Hi 👋🏻 How do you currently use this action? Like, what options offered by this action are you currently using? When I was creating setup-wsl2, I thought of adding the options from this action, but when I read WSL documentation, the defaults seemed just right to me, so I dropped the idea and decided to implement them on request.

@Vampire
Copy link
Owner

Vampire commented Nov 29, 2024

No need to switch, thanks for fiddling out that and how it works in the meantime @vedantmgoyal9, I'll of course add support for WSLv2 here, now that it seems to work.

@Vampire Vampire added this to the Next Version milestone Nov 29, 2024
@vedantmgoyal9
Copy link

vedantmgoyal9 commented Dec 2, 2024

@Vampire do you have any idea how to get environment variables from github actions?

vedantmgoyal9/setup-wsl2#2

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

@vedantmgoyal9 how did you overcome

WslRegisterDistribution failed with error: 0x8007019e

The Windows Subsystem for Linux optional component is not enabled. Please enable it and try again.

?
For quite some tests I get that failure when installing a distribution:
https://github.com/Vampire/setup-wsl/actions/runs/12087128702/job/33782635573#step:3:38

@vedantmgoyal9
Copy link

You need to run this before upgrading WSL:

Set-Service -Name StorSvc -StartupType Automatic

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

Hm, doesn't seem to help.
The StorSvc was disabled on the runner images with actions/runner-images#8388.
I added now an sc config StorSvc start=auto before the wsl --update, but this did not help: https://github.com/Vampire/setup-wsl/actions/runs/12118872416/job/33784581892#step:3:19 :-(

@vedantmgoyal9
Copy link

https://github.com/vedantmgoyal9/setup-wsl2/actions/runs/12119412636
I've added other distros to the test CI and all of them installed successfully. I think it is failing because you're restoring from cache. Try clearing the cache at https://github.com/Vampire/setup-wsl/actions/caches and it should install without any error.

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

But why should the cache cause this?
Unless it is just a timing issue and it is not the cache that is the problem, but just needs a delay and downloading freshly just needs enough time so that it works as symptom treatment.
The cache only caches the downloaded and extracted installer directory.
:-/
Also deleting the cache did not help, probably then because earlier jobs filled the cache again and then the later reused.

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

Also hard-coding use-cache to false makes it works for some but not for others, including that it worked on windows-2022 but not on `windows-latest´ which is an alias for the former. >:-/

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

Yes, that was it, thanks.
It indeed is just typical MS non-sense. :-D
Enabling StorSvc and disabling cache usage are irrelevant per-se.
They just slow down the process and give whatever enough time to settle.
If I simply add a 30 seconds delay after the wsl --update call, all distributions install fine. :-)
Now I just need to find which value is high enough but as low as possible and add some more tests and can then release WSLv2 support. :-)

@vedantmgoyal9
Copy link

So it works without StorSvc? That's cool. When I searched for a fix for WslRegisterDistribution failed with error: 0x8007019e, a comment on GitHub told me to enable this specific service. Also, I never tested with StorSvc kept disabled 😕

By the way, just do a wsl --status and it will hold until the update completes 👍🏻

@vedantmgoyal9
Copy link

By the way, where are you pushing the new code? I can neither see a new commit nor a new branch? 🤷🏻

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

$ git help ptm
'ptm' is aliased to '!git push origin @:refs/heads/test/master && git push origin :refs/heads/test/master'

:-)
Just get to it from https://github.com/Vampire/setup-wsl/actions if you are curious

@vedantmgoyal9
Copy link

I can't :( when I first saw it, I thought you tricked GitHub to not to show in branches section.
image

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

No, not to the branch, that doesn't exist.
For example use the dots menu on the right to "view the workflow file" and then there click on the commit SHA-1.

@Vampire
Copy link
Owner

Vampire commented Dec 2, 2024

By the way, just do a wsl --status and it will hold until the update completes 👍🏻

Thanks, I think that is also not fully true, but just one of the things you did to cause enough time to pass before trying to install. :-D
If I directly after the --update to the --status it says "WSL is finishing an upgrade..." in its output.
So I don't think it waits, you just again gain some implicit wait time.
But anyway thanks for that, because that will be my check for how long to wait, much better than some arbitrary time wait. :-)

@vedantmgoyal9
Copy link

vedantmgoyal9 commented Dec 3, 2024

Thanks, I think that is also not fully true, but just one of the things you did to cause enough time to pass before trying to install. :-D
If I directly after the --update to the --status it says "WSL is finishing an upgrade..." in its output.
So I don't think it waits, you just again gain some implicit wait time.

This time I'm sure it does hold until printing Default Version: 2. You might not see it because the logs might be printed at the same time, but you will notice the "wait" if you RDP to GitHub runners and run commands manually.

@Vampire
Copy link
Owner

Vampire commented Dec 3, 2024

Who knows whether it maybe also behaves differently when running headless. 🤷‍♂️
I'll just go the safe route and wait until the string does not appear anymore. :-)

@Vampire Vampire modified the milestone: Next Version Dec 3, 2024
Vampire added a commit that referenced this issue Dec 4, 2024
@Vampire
Copy link
Owner

Vampire commented Dec 4, 2024

Ok, tests are to my liking now too, and of course @ssbarnea it will be configurable with an input.
But I changed the default to WSLv2 where possible, hence it is a major version bump as this is a breaking change.
If all tests run through properly now, release will come later today.

@Vampire Vampire closed this as completed Dec 4, 2024
@Vampire
Copy link
Owner

Vampire commented Dec 4, 2024

4.0.0 has landed :-)

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

4 participants