Skip to content

Commit e7f8ac3

Browse files
committed
fix: don't use /run/user/ on wsl
1 parent 8896dde commit e7f8ac3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pkg/utils/paths.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ import (
2525
"strings"
2626
)
2727

28+
var isWsl = false
29+
30+
func init() {
31+
osrelease, err := os.ReadFile("/proc/sys/kernel/osrelease")
32+
if err != nil {
33+
isWsl = false
34+
}
35+
isWsl = strings.Contains(string(osrelease), "WSL2")
36+
}
37+
2838
// slashSplitter - used to split strings, with the same output regardless of leading or trailing slashes
2939
// e.g - strings.FieldsFunc("/one/two/three/", f) == strings.FieldsFunc("/one/two/three", f) == strings.FieldsFunc("one/two/three", f) == ["one" "two" "three"]
3040
func slashSplitter(c rune) bool {
@@ -54,7 +64,7 @@ func homeDir() string {
5464

5565
// NitricRunDir returns the directory to place runtime data.
5666
func NitricRunDir() string {
57-
if runtime.GOOS == "linux" {
67+
if runtime.GOOS == "linux" && !isWsl {
5868
u, err := user.Current()
5969
if err != nil {
6070
log.Fatal(err)

0 commit comments

Comments
 (0)