grafana/k6 · error
'%s' is a relative path but could not determine CWD: %w
Error message
'%s' is a relative path but could not determine CWD: %w
What it means
Raised in openFile when the configured log path is relative and the getCwd callback failed, so the relative path cannot be resolved to an absolute one. The underlying getCwd error is wrapped with %w. The at-fault inputs are the relative log path and the failing CWD lookup.
Source
Thrown at internal/log/file.go:93
h.levels, err = parseLevels(token.Value)
if err != nil {
return err
}
default:
return fmt.Errorf("unknown logfile config key %s", token.Key)
}
}
return nil
}
// openFile opens logfile and initializes writers.
func (h *fileHook) openFile(getCwd func() (string, error)) error {
path := h.path
if !filepath.IsAbs(path) {
cwd, err := getCwd()
if err != nil {
return fmt.Errorf("'%s' is a relative path but could not determine CWD: %w", path, err)
}
path = filepath.Join(cwd, path)
}
if _, err := h.fs.Stat(filepath.Dir(path)); errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("provided directory '%s' does not exist", filepath.Dir(path))
}
file, err := h.fs.OpenFile(path, syscall.O_WRONLY|syscall.O_APPEND|syscall.O_CREAT, 0o600)
if err != nil {
return fmt.Errorf("failed to open logfile %s: %w", path, err)
}
h.w = file
h.bw = bufio.NewWriter(file)
return nil
}View on GitHub (pinned to 01ffac6f24)
Solutions
- Use an absolute path for the logfile
- Ensure the process has a valid working directory so CWD can be determined
- Fix the environment cause reported by the wrapped getCwd error
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at internal/log/file.go:93 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/ca3143f9c53d67f2.
Report an issue: GitHub.