Skip to content

Commit 644c113

Browse files
committed
pkg/usrlocalsharelima: add a candidate directory to searching lima-guestagent
When debugging `cmd/limactl` with `dlv dap`, the executable appears as follows: `cmd/limactl/__debug_bin2611107549`. In this case, `limactl` fails to locate `lima-guestagent` relative to the expected executable path and results in the following error: ```json { "level": "fatal", "msg": "failed to find \"lima-guestagent.Linux-aarch64\" binary for \"/Users/norio/ghq/github.com/lima-vm/lima/cmd/limactl/__debug_bin2611107549\", attempted [/Users/norio/ghq/github.com/lima-vm/lima/cmd/limactl/lima-guestagent.Linux-aarch64 /Users/norio/ghq/github.com/lima-vm/lima/cmd/share/lima/lima-guestagent.Linux-aarch64]", "time": "2024-09-24T15:02:23+09:00" } ``` To avoid this error, it was necessary to create a symbolic link (`ln -sf ../_output/share cmd/share`) so that `lima-guestagent*` exists at the expected relative path. This change adds `_output/share/lima/lima-guestagent.*` to the search directories, making the symbolic link creation unnecessary before running `dlv dap` for debugging. Signed-off-by: Norio Nomura <[email protected]>
1 parent cf76139 commit 644c113

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/usrlocalsharelima/usrlocalsharelima.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func Dir() (string, error) {
3636
// self: /usr/local/bin/limactl
3737
selfDir := filepath.Dir(self)
3838
selfDirDir := filepath.Dir(selfDir)
39+
selfDirDirDir := filepath.Dir(selfDirDir)
3940
gaCandidates := []string{
4041
// candidate 0:
4142
// - self: /Applications/Lima.app/Contents/MacOS/limactl
@@ -47,6 +48,11 @@ func Dir() (string, error) {
4748
// - agent: /usr/local/share/lima/lima-guestagent.Linux-x86_64
4849
// - dir: /usr/local/share/lima
4950
filepath.Join(selfDirDir, "share/lima/lima-guestagent."+ostype+"-"+arch),
51+
// candidate 2: lauched by `~/go/bin/dlv dap`
52+
// - self: ${workspaceFolder}/cmd/limactl/__debug_bin_XXXXXX
53+
// - agent: ${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-x86_64
54+
// - dir: ${workspaceFolder}/_output/share/lima
55+
filepath.Join(selfDirDirDir, "_output/share/lima/lima-guestagent."+ostype+"-"+arch),
5056
// TODO: support custom path
5157
}
5258
for _, gaCandidate := range gaCandidates {

0 commit comments

Comments
 (0)