@@ -90,7 +90,7 @@ func provisionWSLDist(name string, imagePath string, prompt string) (string, err
9090
9191 dist := machine .ToDist (name )
9292 fmt .Println (prompt )
93- if err = runCmdPassThrough ("wsl" , "--import" , dist , distTarget , imagePath , "--version" , "2" ); err != nil {
93+ if err = runCmdPassThrough (wutil . FindWSL () , "--import" , dist , distTarget , imagePath , "--version" , "2" ); err != nil {
9494 return "" , fmt .Errorf ("the WSL import of guest OS failed: %w" , err )
9595 }
9696
@@ -446,7 +446,7 @@ func installWslKernel() error {
446446
447447 backoff := 500 * time .Millisecond
448448 for i := 0 ; i < 5 ; i ++ {
449- err = runCmdPassThroughTee (log , "wsl" , "--update" )
449+ err = runCmdPassThroughTee (log , wutil . FindWSL () , "--update" )
450450 if err == nil {
451451 break
452452 }
@@ -556,17 +556,17 @@ func withUser(s string, user string) string {
556556func wslInvoke (dist string , arg ... string ) error {
557557 newArgs := []string {"-u" , "root" , "-d" , dist }
558558 newArgs = append (newArgs , arg ... )
559- return runCmdPassThrough ("wsl" , newArgs ... )
559+ return runCmdPassThrough (wutil . FindWSL () , newArgs ... )
560560}
561561
562562func wslPipe (input string , dist string , arg ... string ) error {
563563 newArgs := []string {"-u" , "root" , "-d" , dist }
564564 newArgs = append (newArgs , arg ... )
565- return pipeCmdPassThrough ("wsl" , input , newArgs ... )
565+ return pipeCmdPassThrough (wutil . FindWSL () , input , newArgs ... )
566566}
567567
568568func wslCreateKeys (identityPath string , dist string ) (string , error ) {
569- return machine .CreateSSHKeysPrefix (identityPath , true , true , "wsl" , "-u" , "root" , "-d" , dist )
569+ return machine .CreateSSHKeysPrefix (identityPath , true , true , wutil . FindWSL () , "-u" , "root" , "-d" , dist )
570570}
571571
572572func runCmdPassThrough (name string , arg ... string ) error {
@@ -631,7 +631,7 @@ func obtainGlobalConfigLock() (*fileLock, error) {
631631}
632632
633633func IsWSLFeatureEnabled () bool {
634- return wutil .SilentExec ("wsl" , "--set-default-version" , "2" ) == nil
634+ return wutil .SilentExec (wutil . FindWSL () , "--set-default-version" , "2" ) == nil
635635}
636636
637637func isWSLRunning (dist string ) (bool , error ) {
@@ -657,7 +657,7 @@ func getAllWSLDistros(running bool) (map[string]struct{}, error) {
657657 if running {
658658 args = append (args , "--running" )
659659 }
660- cmd := exec .Command ("wsl" , args ... )
660+ cmd := exec .Command (wutil . FindWSL () , args ... )
661661 out , err := cmd .StdoutPipe ()
662662 if err != nil {
663663 return nil , err
@@ -681,7 +681,7 @@ func getAllWSLDistros(running bool) (map[string]struct{}, error) {
681681}
682682
683683func isSystemdRunning (dist string ) (bool , error ) {
684- cmd := exec .Command ("wsl" , "-u" , "root" , "-d" , dist , "sh" )
684+ cmd := exec .Command (wutil . FindWSL () , "-u" , "root" , "-d" , dist , "sh" )
685685 cmd .Stdin = strings .NewReader (sysdpid + "\n echo $SYSDPID\n " )
686686 out , err := cmd .StdoutPipe ()
687687 if err != nil {
@@ -706,12 +706,12 @@ func isSystemdRunning(dist string) (bool, error) {
706706}
707707
708708func terminateDist (dist string ) error {
709- cmd := exec .Command ("wsl" , "--terminate" , dist )
709+ cmd := exec .Command (wutil . FindWSL () , "--terminate" , dist )
710710 return cmd .Run ()
711711}
712712
713713func unregisterDist (dist string ) error {
714- cmd := exec .Command ("wsl" , "--unregister" , dist )
714+ cmd := exec .Command (wutil . FindWSL () , "--unregister" , dist )
715715 return cmd .Run ()
716716}
717717
@@ -753,7 +753,7 @@ func getCPUs(name string) (uint64, error) {
753753 if run , _ := isWSLRunning (dist ); ! run {
754754 return 0 , nil
755755 }
756- cmd := exec .Command ("wsl" , "-u" , "root" , "-d" , dist , "nproc" )
756+ cmd := exec .Command (wutil . FindWSL () , "-u" , "root" , "-d" , dist , "nproc" )
757757 out , err := cmd .StdoutPipe ()
758758 if err != nil {
759759 return 0 , err
@@ -777,7 +777,7 @@ func getMem(name string) (uint64, error) {
777777 if run , _ := isWSLRunning (dist ); ! run {
778778 return 0 , nil
779779 }
780- cmd := exec .Command ("wsl" , "-u" , "root" , "-d" , dist , "cat" , "/proc/meminfo" )
780+ cmd := exec .Command (wutil . FindWSL () , "-u" , "root" , "-d" , dist , "cat" , "/proc/meminfo" )
781781 out , err := cmd .StdoutPipe ()
782782 if err != nil {
783783 return 0 , err
0 commit comments