diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 26684aae09a475a50eceeb0daafccacfb45584df..62f5d90b74531081ff4473c1ca3612cdbfc52ae0 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -157,6 +157,15 @@ const defaultVersionTemplate = `{{with .DisplayName}}{{printf "%s " .}}{{end}}{{ ` func Execute() { + // FIXME: config.Load uses slog internally during provider resolution, + // but the file-based logger isn't set up until after config is loaded + // (because the log path depends on the data directory from config). + // This creates a window where slog calls in config.Load leak to + // stderr. We discard early logs here as a workaround. The proper + // fix is to remove slog calls from config.Load and have it return + // warnings/diagnostics instead of logging them as a side effect. + slog.SetDefault(slog.New(slog.DiscardHandler)) + // NOTE: very hacky: we create a colorprofile writer with STDOUT, then make // it forward to a bytes.Buffer, write the colored heartbit to it, and then // finally prepend it in the version template.