air-verse/air · error
error getting absolute path to %v: %w
Error message
error getting absolute path to %v: %w
What it means
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.
Source
Thrown at runner/util.go:280
// Expands a path, resolving any tilde prefixes, dereferencing symbolic links,
// and converting relative paths to absolute. The result will always be an
// absolute path.
// For paths that do not exist on the filesystem, the dereferencing step will
// be skipped.
// An error will be thrown if dereferencing fails due to something other than
// the path not existing on the filesystem.
func expandPath(path string) (string, error) {
expanded := path
if strings.HasPrefix(path, "~/") {
home := os.Getenv("HOME")
expanded = filepath.Join(home, path[1:])
}
expanded, err := filepath.Abs(expanded)
if err != nil {
return "", fmt.Errorf("error getting absolute path to %v: %w", expanded, err)
}
// filepath.EvalSymlinks only works on real files
dereferenced, err := filepath.EvalSymlinks(expanded)
if err == nil {
return dereferenced, nil
}
if !errors.Is(err, fs.ErrNotExist) {
return "", fmt.Errorf("unexpected error while dereferencing %v: %w", expanded, err)
}
return expanded, nil
}
func isDir(path string) bool {
i, err := os.Stat(path)
if err != nil {View on GitHub (pinned to 71ea1dee05)
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
Example fix
// before: script does `rm -rf build && cd build && air` // after mkdir -p build && cd build && air
Defensive patterns
Strategy: try-catch
Validate before calling
// verify cwd is resolvable before starting air
if _, err := os.Getwd(); err != nil {
return fmt.Errorf("working directory unavailable: %w", err)
} Try / catch
_, err := os.Stat(path)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
// cwd or path vanished; re-cd into project and retry
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unexpected error while dereferencing %v: %w
- failed to check for existing configuration: %w
- failed to create a new configuration: %w
- failed to write to %s: %w
AI-assisted analysis of air-verse/air@71ea1dee05 (2026-08-31).
Data as JSON: /api/errors/1ca97c564c4334f7.
Report an issue: GitHub.