{"record":{"id":"ca3143f9c53d67f2","repo":"grafana/k6","slug":"s-is-a-relative-path-but-could-not-determine-cw","errorCode":null,"errorMessage":"'%s' is a relative path but could not determine CWD: %w","messagePattern":"'(.+?)' is a relative path but could not determine CWD: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/log/file.go","lineNumber":93,"sourceCode":"\t\t\th.levels, err = parseLevels(token.Value)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown logfile config key %s\", token.Key)\n\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}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/log/file.go#L75-L111","documentation":"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.","triggerScenarios":"Thrown at internal/log/file.go:93 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","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"}