{"record":{"id":"f6b7f9f7a1621c9b","repo":"juanfont/headscale","slug":"getting-absolute-path-for-logs-directory-w","errorCode":null,"errorMessage":"getting absolute path for logs directory: %w","messagePattern":"getting absolute path for logs directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/hi/docker.go","lineNumber":57,"sourceCode":"\tcli, err := createDockerClient(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"creating Docker client: %w\", err)\n\t}\n\tdefer cli.Close()\n\n\trunID := dockertestutil.GenerateRunID()\n\tcontainerName := \"headscale-test-suite-\" + runID\n\tlogsDir := filepath.Join(config.LogsDir, runID)\n\n\tif config.Verbose {\n\t\tlog.Printf(\"Run ID: %s\", runID)\n\t\tlog.Printf(\"Container name: %s\", containerName)\n\t\tlog.Printf(\"Logs directory: %s\", logsDir)\n\t}\n\n\tabsLogsDir, err := filepath.Abs(logsDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting absolute path for logs directory: %w\", err)\n\t}\n\n\tconst dirPerm = 0o755\n\tif err := os.MkdirAll(absLogsDir, dirPerm); err != nil { //nolint:noinlineerr\n\t\treturn fmt.Errorf(\"creating logs directory: %w\", err)\n\t}\n\n\tif config.CleanBefore {\n\t\tif config.Verbose {\n\t\t\tlog.Printf(\"Running pre-test cleanup...\")\n\t\t}\n\n\t\terr := cleanupBeforeTest(ctx)\n\t\tif err != nil && config.Verbose {\n\t\t\tlog.Printf(\"Warning: pre-test cleanup failed: %v\", err)\n\t\t}\n\t}\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/cmd/hi/docker.go#L39-L75","documentation":"Returned by runTestContainer when filepath.Abs on the per-run logs directory (LogsDir/<runID>) fails. filepath.Abs almost only fails when os.Getwd fails — the process's working directory was deleted or is unreadable. The relative logs path itself is irrelevant; the failure is about the current working directory.","triggerScenarios":"Starting an `hi run` from a directory that was deleted (e.g. a removed temp/worktree dir) while the shell still sits in it; cwd with unreadable parents; exotic environments where getwd(2) fails.","commonSituations":"Running hi from a git worktree that another process removed; scripts that cd into build dirs later deleted; sandboxed environments blocking getcwd.","solutions":["cd into an existing directory and re-run the command","Restore or recreate the deleted working directory","Check for unreadable parent directories on the cwd path"],"exampleFix":"# before (shell sits in a deleted directory)\ngo run ./cmd/hi run TestACL   # getting absolute path for logs directory: ...\n\n# after\ncd /path/to/headscale\ngo run ./cmd/hi run TestACL","handlingStrategy":"validation","validationCode":"// Verify the cwd exists before launching hi.\nif _, err := os.Getwd(); err != nil {\n\tfmt.Fprintln(os.Stderr, \"working directory is gone — cd to a valid dir\")\n\tos.Exit(1)\n}","typeGuard":null,"tryCatchPattern":"Not retriable as-is: re-run the command from an existing directory. In Go, check os.Getwd error explicitly when resolving relative paths.","preventionTips":["Re-enter the repo directory after worktree/branch restructuring before running hi","Avoid running long-lived shells from temp directories that cleanup jobs may remove"],"tags":["filesystem","working-directory","integration-tests","hi"],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}