{"record":{"id":"1ca97c564c4334f7","repo":"air-verse/air","slug":"error-getting-absolute-path-to-v-w","errorCode":null,"errorMessage":"error getting absolute path to %v: %w","messagePattern":"error getting absolute path to (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"runner/util.go","lineNumber":280,"sourceCode":"\n// Expands a path, resolving any tilde prefixes, dereferencing symbolic links,\n// and converting relative paths to absolute. The result will always be an\n// absolute path.\n// For paths that do not exist on the filesystem, the dereferencing step will\n// be skipped.\n// An error will be thrown if dereferencing fails due to something other than\n// the path not existing on the filesystem.\nfunc expandPath(path string) (string, error) {\n\texpanded := path\n\n\tif strings.HasPrefix(path, \"~/\") {\n\t\thome := os.Getenv(\"HOME\")\n\t\texpanded = filepath.Join(home, path[1:])\n\t}\n\n\texpanded, err := filepath.Abs(expanded)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error getting absolute path to %v: %w\", expanded, err)\n\t}\n\n\t// filepath.EvalSymlinks only works on real files\n\tdereferenced, err := filepath.EvalSymlinks(expanded)\n\tif err == nil {\n\t\treturn dereferenced, nil\n\t}\n\n\tif !errors.Is(err, fs.ErrNotExist) {\n\t\treturn \"\", fmt.Errorf(\"unexpected error while dereferencing %v: %w\", expanded, err)\n\t}\n\n\treturn expanded, nil\n}\n\nfunc isDir(path string) bool {\n\ti, err := os.Stat(path)\n\tif err != nil {","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/air-verse/air/blob/71ea1dee05248122ed22b5870c7fb20a90d80ddd/runner/util.go#L262-L298","documentation":"expandPath resolves ~, symlinks, and relative components, then calls filepath.Abs; if Abs fails (e.g. working directory was deleted or path construction fails) it wraps the error with this message and propagates it up through preprocess, aborting path resolution.","triggerScenarios":"Calling expandPath (via preprocess during config load) when os.Getwd (used by filepath.Abs) fails because the current working directory has been removed, or with malformed path input that Abs cannot absolutize.","commonSituations":"Running air from a deleted directory (common after scripts rm -rf their own cwd); containerized environments where workdir vanished; permission problems on the current directory.","solutions":["Re-run air from an existing directory (cd to your project and retry)","Check that the working directory still exists: `pwd` should succeed in the same shell","Inspect the wrapped %w error for the OS-level cause (ENOENT, EACCES) and fix it","Update any scripts/CI that delete and recreate the directory air runs in"],"exampleFix":"// before: script does `rm -rf build && cd build && air`\n// after\nmkdir -p build && cd build && air","handlingStrategy":"try-catch","validationCode":"// verify cwd is resolvable before starting air\nif _, err := os.Getwd(); err != nil {\n\treturn fmt.Errorf(\"working directory unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"_, err := os.Stat(path)\nif err != nil {\n\tif errors.Is(err, fs.ErrNotExist) {\n\t\t// cwd or path vanished; re-cd into project and retry\n\t}\n\treturn err\n}","preventionTips":["Never rm -rf the directory air is running in from the same script","Use absolute, pre-created working directories in CI","Check shell cwd validity after container mounts change","Add a `pwd` sanity check in launch scripts"],"tags":["filesystem","path"],"backgroundTag":"filepath-resolution-failure","analyzedSha":"71ea1dee05248122ed22b5870c7fb20a90d80ddd","analyzedAt":"2026-08-31T20:27:54.676Z","schemaVersion":2},"datasetVersion":"2026-09-01T03:17:15.561Z"}