diff --git a/internal/debug/caller.go b/internal/debug/caller.go index adc8465e0..690cad15f 100644 --- a/internal/debug/caller.go +++ b/internal/debug/caller.go @@ -15,6 +15,7 @@ package debug import ( + "errors" "fmt" "os/exec" "path" @@ -34,12 +35,20 @@ func FirstCaller() (file string, line int, ok bool) { ebitengineFileDirOnce.Do(func() { cmd := exec.Command("go", "list", "-f", "{{.Dir}}", "github.com/hajimehoshi/ebiten/v2") out, err := cmd.Output() + if errors.Is(err, exec.ErrNotFound) { + return + } if err != nil { panic(fmt.Sprintf("debug: go list -f {{.Dir}} failed: %v", err)) } ebitengineFileDir = filepath.ToSlash(strings.TrimSpace(string(out))) }) + // Go command is not found. + if ebitengineFileDir == "" { + return "", 0, false + } + // Relying on a caller stacktrace is very fragile, but this is fine as this is only for debugging. var ebitenPackageReached bool for i := 0; ; i++ { diff --git a/internal/graphicscommand/commandqueue.go b/internal/graphicscommand/commandqueue.go index 574776d3a..72e3940e6 100644 --- a/internal/graphicscommand/commandqueue.go +++ b/internal/graphicscommand/commandqueue.go @@ -166,8 +166,6 @@ func (q *commandQueue) EnqueueDrawTrianglesCommand(dst *Image, srcs [graphics.Sh if debug.IsDebug { if file, line, ok := debug.FirstCaller(); ok { c.firstCaller = fmt.Sprintf("%s:%d", file, line) - } else { - c.firstCaller = "(internal)" } } q.commands = append(q.commands, c)