Skip to content

Commit 9c75559

Browse files
committed
pkg/usrlocalsharelima: add lima-guestagent location candidates only when logrus.GetLevel() == logrus.DebugLevel.
Signed-off-by: Norio Nomura <[email protected]>
1 parent 644c113 commit 9c75559

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/usrlocalsharelima/usrlocalsharelima.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"runtime"
1010

1111
"github.com/lima-vm/lima/pkg/limayaml"
12+
"github.com/sirupsen/logrus"
1213
)
1314

1415
func Dir() (string, error) {
@@ -36,7 +37,6 @@ func Dir() (string, error) {
3637
// self: /usr/local/bin/limactl
3738
selfDir := filepath.Dir(self)
3839
selfDirDir := filepath.Dir(selfDir)
39-
selfDirDirDir := filepath.Dir(selfDirDir)
4040
gaCandidates := []string{
4141
// candidate 0:
4242
// - self: /Applications/Lima.app/Contents/MacOS/limactl
@@ -48,12 +48,16 @@ func Dir() (string, error) {
4848
// - agent: /usr/local/share/lima/lima-guestagent.Linux-x86_64
4949
// - dir: /usr/local/share/lima
5050
filepath.Join(selfDirDir, "share/lima/lima-guestagent."+ostype+"-"+arch),
51+
// TODO: support custom path
52+
}
53+
if logrus.GetLevel() == logrus.DebugLevel {
5154
// candidate 2: lauched by `~/go/bin/dlv dap`
5255
// - self: ${workspaceFolder}/cmd/limactl/__debug_bin_XXXXXX
5356
// - agent: ${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-x86_64
5457
// - dir: ${workspaceFolder}/_output/share/lima
55-
filepath.Join(selfDirDirDir, "_output/share/lima/lima-guestagent."+ostype+"-"+arch),
56-
// TODO: support custom path
58+
candidateForDebugBuild := filepath.Join(filepath.Dir(selfDirDir), "_output/share/lima/lima-guestagent."+ostype+"-"+arch)
59+
gaCandidates = append(gaCandidates, candidateForDebugBuild)
60+
logrus.Infof("debug build detected, adding more guest agent candidates: %v", candidateForDebugBuild)
5761
}
5862
for _, gaCandidate := range gaCandidates {
5963
if _, err := os.Stat(gaCandidate); err == nil {

0 commit comments

Comments
 (0)