From 11ccaffa766cba9c4886aff8ee44100bfa822fde Mon Sep 17 00:00:00 2001 From: Jan Dubois Date: Thu, 14 Oct 2021 14:43:19 -0700 Subject: [PATCH] Evaluate symlinks in LIMA_HOME This allows the user to replace the directory with a symlink in case the path is too long to successfully create a socket underneath. Signed-off-by: Jan Dubois --- pkg/store/dirnames/dirnames.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/store/dirnames/dirnames.go b/pkg/store/dirnames/dirnames.go index 6e4b897a4dd..0e91c6a6e0c 100644 --- a/pkg/store/dirnames/dirnames.go +++ b/pkg/store/dirnames/dirnames.go @@ -1,8 +1,10 @@ package dirnames import ( - "path/filepath" + "errors" + "fmt" "os" + "path/filepath" "github.com/lima-vm/lima/pkg/store/filenames" ) @@ -24,7 +26,14 @@ func LimaDir() (string, error) { } dir = filepath.Join(homeDir, DotLima) } - return dir, nil + if _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) { + return dir, nil + } + realdir, err := filepath.EvalSymlinks(dir) + if err != nil { + return "", fmt.Errorf("cannot evaluate symlinks in %q: %w", dir, err) + } + return realdir, nil } // LimaConfigDir returns the path of the config directory, $LIMA_HOME/_config.