Skip to content

Commit f8abb3d

Browse files
committed
usrlocalsharelima: execute Dir() once
Stop spamming info messages on using `--debug`. e.g.: ```console $ limactl prune --keep-referred --debug DEBU[0000] Mixing "/Users/norio/.lima/_config/override.yaml" into "/Users/norio/.lima/debug/lima.yaml" INFO[0000] debug mode detected, adding more guest agent candidates: /Users/norio/ghq/github.com/lima-vm/lima/_output/share/lima/lima-guestagent.Linux-aarch64 DEBU[0000] Discovering external drivers in /Users/norio/ghq/github.com/lima-vm/lima/_output/libexec/lima INFO[0000] debug mode detected, adding more guest agent candidates: /Users/norio/ghq/github.com/lima-vm/lima/_output/share/lima/lima-guestagent.Linux-aarch64 DEBU[0000] Discovering external drivers in /Users/norio/ghq/github.com/lima-vm/lima/_output/libexec/lima ... ``` Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
1 parent 2105d57 commit f8abb3d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/usrlocalsharelima/usrlocalsharelima.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var executableViaArgs0 = sync.OnceValues(func() (string, error) {
4444
// Dir returns the location of the <PREFIX>/lima/share directory, relative to the location
4545
// of the current executable. It checks for multiple possible filesystem layouts and returns
4646
// the first candidate that contains the native guest agent binary.
47-
func Dir() (string, error) {
47+
var Dir = sync.OnceValues(func() (string, error) {
4848
selfPaths := []string{}
4949

5050
selfViaArgs0, err := executableViaArgs0()
@@ -119,7 +119,7 @@ func Dir() (string, error) {
119119

120120
return "", fmt.Errorf("failed to find \"lima-guestagent.%s-%s\" binary for %v, attempted %v",
121121
ostype, arch, selfPaths, gaCandidates)
122-
}
122+
})
123123

124124
// GuestAgentBinary returns the absolute path of the guest agent binary, possibly with ".gz" suffix.
125125
func GuestAgentBinary(ostype limatype.OS, arch limatype.Arch) (string, error) {

0 commit comments

Comments
 (0)