Skip to content

Commit

Permalink
Evaluate symlinks in LIMA_HOME
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jandubois committed Oct 14, 2021
1 parent b843fe7 commit 11ccaff
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/store/dirnames/dirnames.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package dirnames

import (
"path/filepath"
"errors"
"fmt"
"os"
"path/filepath"

"github.com/lima-vm/lima/pkg/store/filenames"
)
Expand All @@ -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.
Expand Down

0 comments on commit 11ccaff

Please sign in to comment.