txthinking/brook · error

--log must be with absolute path

Error message

--log must be with absolute path

What it means

The CLI validates --log in app.Before: the value must be either the literal "console" or an absolute file path. Anything else (relative path) is rejected so log output location is deterministic. Execution aborts before the subcommand runs.

Source

Thrown at cli/brook/main.go:191

			}
		}
		if c.String("pprof") != "" {
			p, err := pprof.NewPprof(c.String("pprof"))
			if err != nil {
				return err
			}
			g.Add(&runnergroup.Runner{
				Start: func() error {
					return p.ListenAndServe()
				},
				Stop: func() error {
					return p.Shutdown()
				},
			})
		}
		if c.String("log") != "" {
			if c.String("log") != "console" && !filepath.IsAbs(c.String("log")) {
				return errors.New("--log must be with absolute path")
			}
			var m map[string]string
			if len(c.StringSlice("tag")) > 0 {
				m = make(map[string]string)
				for _, v := range c.StringSlice("tag") {
					l := strings.Split(v, ":")
					if len(l) != 2 {
						return errors.New("Invalid tag " + v)
					}
					m[l[0]] = l[1]
				}
			}
			p, err := logger.NewLogger(m, c.String("log"))
			if err != nil {
				return err
			}
			p.TouchBrook()
			f := df

View on GitHub (pinned to 5cd13ef3b1)

Solutions

  1. Use an absolute path: --log /var/log/brook.log
  2. Use --log console to log to stdout/stderr instead of a file
  3. Convert the path to absolute in the wrapper script: --log "$PWD/brook.log"

Example fix

// before
brook server -l :9999 --log logs/brook.log
// after
brook server -l :9999 --log /var/log/brook.log
Defensive patterns

Strategy: validation

Validate before calling

if logPath != "" && logPath != "console" && !filepath.IsAbs(logPath) {
	return fmt.Errorf("--log must be "console" or absolute, got %q", logPath)
}

Prevention

When it happens

Trigger: Running any brook subcommand with --log brook.log or --log ./logs/brook.log (relative path), i.e. neither "console" nor an absolute path.

Common situations: Relative log paths in example configs; container images where the working directory changes; operators intending console output but passing a filename.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of txthinking/brook@5cd13ef3b1 (2026-09-06). Data as JSON: /api/errors/89e0e0d0e1d6551c. Report an issue: GitHub.