Skip to content

Commit 0ac8438

Browse files
authored
Merge pull request #2694 from AkihiroSuda/fix-2684
Fix '"debug build detected" is always printed' issue
2 parents 149aa11 + 3f112ab commit 0ac8438

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

cmd/lima-guestagent/main_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"strings"
55

6+
"github.com/lima-vm/lima/pkg/debugutil"
67
"github.com/lima-vm/lima/pkg/version"
78
"github.com/sirupsen/logrus"
89
"github.com/spf13/cobra"
@@ -25,6 +26,7 @@ func newApp() *cobra.Command {
2526
debug, _ := cmd.Flags().GetBool("debug")
2627
if debug {
2728
logrus.SetLevel(logrus.DebugLevel)
29+
debugutil.Debug = true
2830
}
2931
return nil
3032
}

cmd/limactl/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"runtime"
99
"strings"
1010

11+
"github.com/lima-vm/lima/pkg/debugutil"
1112
"github.com/lima-vm/lima/pkg/fsutil"
1213
"github.com/lima-vm/lima/pkg/osutil"
1314
"github.com/lima-vm/lima/pkg/store/dirnames"
@@ -94,6 +95,7 @@ func newApp() *cobra.Command {
9495
debug, _ := cmd.Flags().GetBool("debug")
9596
if debug {
9697
logrus.SetLevel(logrus.DebugLevel)
98+
debugutil.Debug = true
9799
}
98100

99101
if osutil.IsBeingRosettaTranslated() && cmd.Parent().Name() != "completion" && cmd.Name() != "generate-doc" && cmd.Name() != "validate" {

pkg/debugutil/debugutil.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package debugutil
2+
3+
// Debug is set via main.
4+
var Debug bool

pkg/usrlocalsharelima/usrlocalsharelima.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path/filepath"
99
"runtime"
1010

11+
"github.com/lima-vm/lima/pkg/debugutil"
1112
"github.com/lima-vm/lima/pkg/limayaml"
1213
"github.com/sirupsen/logrus"
1314
)
@@ -50,14 +51,14 @@ func Dir() (string, error) {
5051
filepath.Join(selfDirDir, "share/lima/lima-guestagent."+ostype+"-"+arch),
5152
// TODO: support custom path
5253
}
53-
if logrus.GetLevel() == logrus.DebugLevel {
54+
if debugutil.Debug {
5455
// candidate 2: lauched by `~/go/bin/dlv dap`
5556
// - self: ${workspaceFolder}/cmd/limactl/__debug_bin_XXXXXX
5657
// - agent: ${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-x86_64
5758
// - dir: ${workspaceFolder}/_output/share/lima
5859
candidateForDebugBuild := filepath.Join(filepath.Dir(selfDirDir), "_output/share/lima/lima-guestagent."+ostype+"-"+arch)
5960
gaCandidates = append(gaCandidates, candidateForDebugBuild)
60-
logrus.Infof("debug build detected, adding more guest agent candidates: %v", candidateForDebugBuild)
61+
logrus.Infof("debug mode detected, adding more guest agent candidates: %v", candidateForDebugBuild)
6162
}
6263
for _, gaCandidate := range gaCandidates {
6364
if _, err := os.Stat(gaCandidate); err == nil {

0 commit comments

Comments
 (0)