os.path.realpath
Cutting through symlinks to find the real file
- path_in
- path
You've got a model folder on a second drive, symlinked into models/ - the standard "my C: drive is full" setup. ComfyUI resolves the link fine, but the path your workflow sees is the symlinked one, and every downstream tool that touches the file sees a different string depending on whether it follows links. os.path.realpath resolves the whole chain: follow every symlink in the path and return the canonical, real location on disk.
It's from the ovum/path/os.path family in comfy-ovum, a wrapper over Python's os.path.realpath(). Same behavior as the stdlib, including how it handles .. and repeated separators.
How it works
Resolves the path against the filesystem - following symlinks component by component - and returns the canonical absolute path as a STRING (path). Inputs:
- path (STRING, required): the widget.
- forward_slashes (BOOLEAN, required, default false): convert backslashes to forward slashes in the output.
- path_in (PATHLIKE,STRING, optional): link-only; overrides the widget when connected.
One STRING out. Unlike normpath, this actually touches the filesystem - which is both its power and its catch.
Where you'd use it
- Canonicalizing model paths. If you're building logic that compares, dedups, or logs model files, run every path through
realpathfirst so the symlinked copy and the real file report the same string. Otherwise "is model X the same as model Y" gives you a false "no" when one is reached via a link. - Handing paths to tools that choke on symlinks. Some pipelines, archive tools, and external scripts behave oddly when given a symlinked path (double-processing, weird relative resolutions). Realpath gives them the physical path and the weirdness goes away.
- Diagnosing broken links. Combined with
os.path.islink, realpath is how you discover where a path actually lands.realpathon a broken symlink returns the path of the non-existent target - which is exactly the diagnostic you want.
Installing it
Pack-wide install, once:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Or ComfyUI Manager → "comfy-ovum" → Install → restart. No models, no extra deps.
Gotchas
- The path must exist (mostly).
realpathresolves symlinks by stat'ing them. A path whose intermediate components don't exist will be normalized textually but the symlink resolution just doesn't happen - you get a tidied absolute path, not a real one. If the file is gone, check withos.path.lexistsbefore trusting the result. - It's the physical path. Use it where you want the real file; don't use it if you want to preserve the symlinked view (some workflows intentionally write through the link).
- Slower than the string-only nodes. Realpath does actual filesystem calls per component. Fine in a graph, but it's not the "always run this on everything" node the way
normpathis - use it where symlinks actually exist.
Between normpath (lexical cleanup, no disk) and realpath (physical resolution, needs disk), you've got the two ends of the canonicalization spectrum. Realpath is the heavier hammer - bring it out when symlinks are actually in play.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| path | STRING | — | |
| forward_slashes | BOOLEAN | false | — |
| path_inopt | PATHLIKE,STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| path | STRING | — |