charmbracelet/glow · error

unable to get absolute path: %w

Error message

unable to get absolute path: %w

What it means

After successfully opening the file, glow labels the source with filepath.Abs(arg), which resolves the path relative to the current working directory. filepath.Abs only fails when os.Getwd() fails - i.e. the process's current directory was deleted, renamed, or became unreadable. This is an extremely rare condition distinct from any problem with the file itself.

Source

Thrown at main.go:147

				}
			}
			return nil
		})

		if src != nil {
			return src, nil
		}

		return nil, errors.New("missing markdown source")
	}

	r, err := os.Open(arg)
	if err != nil {
		return nil, fmt.Errorf("unable to open file: %w", err)
	}
	u, err := filepath.Abs(arg)
	if err != nil {
		return nil, fmt.Errorf("unable to get absolute path: %w", err)
	}
	return &source{r, u}, nil
}

// validateStyle checks if the style is a default style, if not, checks that
// the custom style exists.
func validateStyle(style string) error {
	if style != "auto" && styles.DefaultStyles[style] == nil {
		style = utils.ExpandPath(style)
		if _, err := os.Stat(style); errors.Is(err, fs.ErrNotExist) {
			return fmt.Errorf("specified style does not exist: %s", style)
		} else if err != nil {
			return fmt.Errorf("unable to stat file: %w", err)
		}
	}
	return nil
}

View on GitHub (pinned to e3970c813d)

Solutions

  1. Check that the current directory still exists: pwd
  2. Re-run glow from a valid directory (cd to a stable path first)
  3. In scripts, avoid deleting the working directory while tools still run from it
Defensive patterns

Strategy: validation

Validate before calling

func cwdValid() bool {
	wd, err := os.Getwd()
	return err == nil && wd != ""
}

Prevention

When it happens

Trigger: The directory glow was started in is deleted (rm -rf) while the process runs; the cwd's permissions are revoked; the cwd sits on an unmounted/dead filesystem.

Common situations: Scripts that delete their working directory before invoking tools, containers where the workdir is removed by another process, long-lived shells in cleaned-up temp dirs.

Related errors


AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15). Data as JSON: /api/errors/0b1fbd79abf91d6c. Report an issue: GitHub.