grafana/k6 · error

provided directory '%s' does not exist

Error message

provided directory '%s' does not exist

What it means

A validation guard in openFile: the directory portion of the resolved log path does not exist on the configured filesystem (Stat returned ErrNotExist), so the log file cannot be created there. The at-fault input is the non-existent directory of the configured log path.

Source

Thrown at internal/log/file.go:99

		}
	}

	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
}

// Listen waits for log lines to flush.
func (h *fileHook) Listen(ctx context.Context) {
	ticker := time.NewTicker(fileHookFlushInterval)
	defer ticker.Stop()

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Create the directory before running k6 (mkdir -p path/to/dir)
  2. Point file= at an existing directory
  3. Check the path for typos, especially when it was made absolute by joining with CWD
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/log/file.go:99 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/6d7e2b21166217ba. Report an issue: GitHub.