@@ -738,7 +738,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string, warn bool) {
738738 location := make (map [string ]int )
739739 for _ , mount := range slices .Concat (d .Mounts , y .Mounts , o .Mounts ) {
740740 if out , err := executeHostTemplate (mount .Location , instDir , y .Param ); err == nil {
741- mount .Location = out .String ()
741+ mount .Location = filepath . Clean ( out .String () )
742742 } else {
743743 logrus .WithError (err ).Warnf ("Couldn't process mount location %q as a template" , mount .Location )
744744 }
@@ -955,14 +955,22 @@ func executeHostTemplate(format, instDir string, param map[string]string) (bytes
955955 tmpl , err := template .New ("" ).Parse (format )
956956 if err == nil {
957957 limaHome , _ := dirnames .LimaDir ()
958+ globalTempDir := "/tmp"
959+ if runtime .GOOS == "windows" {
960+ // On Windows the global temp directory "%SystemRoot%\Temp" (normally "C:\Windows\Temp")
961+ // is not writable by regular users.
962+ globalTempDir = os .TempDir ()
963+ }
958964 data := map [string ]any {
959965 "Dir" : instDir ,
960966 "Name" : filepath .Base (instDir ),
961967 // TODO: add hostname fields for the host and the guest
962- "UID" : currentUser .Uid ,
963- "User" : currentUser .Username ,
964- "Home" : userHomeDir ,
965- "Param" : param ,
968+ "UID" : currentUser .Uid ,
969+ "User" : currentUser .Username ,
970+ "Home" : userHomeDir ,
971+ "Param" : param ,
972+ "GlobalTempDir" : globalTempDir ,
973+ "TempDir" : os .TempDir (),
966974
967975 "Instance" : filepath .Base (instDir ), // DEPRECATED, use `{{.Name}}`
968976 "LimaHome" : limaHome , // DEPRECATED, use `{{.Dir}}` instead of `{{.LimaHome}}/{{.Instance}}`
0 commit comments