Skip to content

Commit b668567

Browse files
authored
Merge pull request #3654 from AkinoKaede/self-lookup-nonlinux
Search for the data directory using real executable on non-Linux platform
2 parents c03f734 + 8c09d70 commit b668567

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/usrlocalsharelima/usrlocalsharelima.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,16 @@ func Dir() (string, error) {
5757
selfViaOS, err := os.Executable()
5858
if err != nil {
5959
logrus.WithError(err).Warn("failed to find os.Executable()")
60-
} else if len(selfPaths) == 0 || selfViaOS != selfPaths[0] {
61-
selfPaths = append(selfPaths, selfViaOS)
60+
} else {
61+
selfFinalPathViaOS, err := filepath.EvalSymlinks(selfViaOS)
62+
if err != nil {
63+
logrus.WithError(err).Warn("failed to resolve symlinks")
64+
selfFinalPathViaOS = selfViaOS // fallback to the original path
65+
}
66+
67+
if len(selfPaths) == 0 || selfFinalPathViaOS != selfPaths[0] {
68+
selfPaths = append(selfPaths, selfFinalPathViaOS)
69+
}
6270
}
6371

6472
ostype := limayaml.NewOS("linux")

0 commit comments

Comments
 (0)