Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22c22c7

Browse files
committed
Fix bug in a Non-English language WSL environment
1 parent 82911c8 commit 22c22c7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

wsl/wsl.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (w *WSL) ConvertToLinuxPath(windowsPath string) (path string, err error) {
6767

6868
func GetDefaultDistribution() (distribution string, err error) {
6969
var result []byte
70-
cmd := exec.Command("wsl", "--status")
71-
regex := regexp.MustCompile(`Default Distribution: (\S+)?`)
70+
cmd := exec.Command("wsl", "--list", "--verbose")
71+
regex := regexp.MustCompile(`^\* (\S+)\s+(Running|Stopped)\s+\d`)
7272

7373
if result, err = cmd.Output(); nil != err {
7474
return "", err
@@ -88,7 +88,7 @@ func GetDefaultDistribution() (distribution string, err error) {
8888

8989
func ValidateDistribution(distribution string) (isValid bool, err error) {
9090
var result []byte
91-
cmd := exec.Command("wsl", "-l")
91+
cmd := exec.Command("wsl", "--list")
9292

9393
if result, err = cmd.Output(); nil != err {
9494
return false, err
@@ -108,7 +108,7 @@ func ValidateDistribution(distribution string) (isValid bool, err error) {
108108

109109
func GetValidDistributions() []string {
110110
distributions := make([]string, 0)
111-
cmd := exec.Command("wsl", "-l")
111+
cmd := exec.Command("wsl", "--list")
112112

113113
if result, err := cmd.Output(); nil == err {
114114
for _, line := range strings.Split(string(result), "\n") {

0 commit comments

Comments
 (0)