{"record":{"id":"6d7e2b21166217ba","repo":"grafana/k6","slug":"provided-directory-s-does-not-exist","errorCode":null,"errorMessage":"provided directory '%s' does not exist","messagePattern":"provided directory '(.+?)' does not exist","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/log/file.go","lineNumber":99,"sourceCode":"\t\t}\n\t}\n\n\treturn nil\n}\n\n// openFile opens logfile and initializes writers.\nfunc (h *fileHook) openFile(getCwd func() (string, error)) error {\n\tpath := h.path\n\tif !filepath.IsAbs(path) {\n\t\tcwd, err := getCwd()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"'%s' is a relative path but could not determine CWD: %w\", path, err)\n\t\t}\n\t\tpath = filepath.Join(cwd, path)\n\t}\n\n\tif _, err := h.fs.Stat(filepath.Dir(path)); errors.Is(err, fs.ErrNotExist) {\n\t\treturn fmt.Errorf(\"provided directory '%s' does not exist\", filepath.Dir(path))\n\t}\n\n\tfile, err := h.fs.OpenFile(path, syscall.O_WRONLY|syscall.O_APPEND|syscall.O_CREAT, 0o600)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to open logfile %s: %w\", path, err)\n\t}\n\n\th.w = file\n\th.bw = bufio.NewWriter(file)\n\n\treturn nil\n}\n\n// Listen waits for log lines to flush.\nfunc (h *fileHook) Listen(ctx context.Context) {\n\tticker := time.NewTicker(fileHookFlushInterval)\n\tdefer ticker.Stop()\n","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/log/file.go#L81-L117","documentation":"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.","triggerScenarios":"Thrown at internal/log/file.go:99 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the directory before running k6 (mkdir -p path/to/dir)","Point file= at an existing directory","Check the path for typos, especially when it was made absolute by joining with CWD"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}