What Is an Absolute Path? A Full Location from Root
An absolute path describes a file's complete location starting from the filesystem root, so it means the same thing regardless of the working directory.
An absolute path spells out exactly where a file is, beginning at the root of the filesystem. Because it does not depend on where you currently are, it is unambiguous. In CI, where the working directory can shift between steps, absolute paths are a reliable way to refer to files without surprises.
What an absolute path is
An absolute path starts at the root: on Linux and macOS it begins with /, as in /home/runner/work/repo/build. It pins down a location independent of any process's current directory.
Absolute versus relative
A relative path is interpreted from the working directory; an absolute path is not. /etc/hosts always means the same file, while config/hosts depends on where you are when you use it.
When to prefer absolute paths
- When the working directory may change or is uncertain.
- When passing a path between steps or processes.
- When a script must run from any location.
Building absolute paths
Scripts often derive an absolute base with something like ROOT="$(pwd)" early on, then build paths from it. This avoids depending on a later cd that might change the working directory.
Absolute paths in CI
Because each CI step may start in a different working directory, referencing files by absolute path removes ambiguity. CI platforms expose the workspace root as an environment variable you can anchor paths to.
Stable references on managed runners
On Latchkey runners, the workspace path is consistent within a job, so anchoring to it with an absolute base keeps file references valid across steps even as the working directory changes.
Key takeaways
- An absolute path gives a file's full location starting from the root.
- It is independent of the working directory, unlike a relative path.
- In CI, absolute paths avoid breakage when the cwd changes between steps.