Skip to content

Commit

Permalink
Set default WSL version to 1 before install (#28)
Browse files Browse the repository at this point in the history
In windows-2022 environment WSLv2 is now generally available and the default,
but it cannot work as GitHub actions are running on Azure cloud where nested
Hyper-V virtualization is not available.

GitHub will change the default WSL version back to WSLv1 in a future update
but to be future proof and not break again in case WSLv2 becomes properly
available in the future, we force it additionally in the action.
  • Loading branch information
Vampire committed Jun 16, 2022
1 parent e3c3146 commit 9a21b37
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/kotlin/net/kautler/github/action/setup_wsl/SetupWsl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ suspend fun verifyWindowsEnvironment() {
}

suspend fun installDistribution() {
exec(
commandLine = "wsl",
args = arrayOf("--set-default-version", "1"),
jsObject {
// ignore a failure in case WSLv2 is not available
// at all and thus `--set-default-version` is not
// a valid option for `wsl` at all
ignoreReturnCode = true
}
).await()
exec(
commandLine = """"${path.join(distributionDirectory(), distribution.installerFile)}"""",
args = arrayOf("install", "--root"),
Expand Down

0 comments on commit 9a21b37

Please sign in to comment.