ComfyUI Node

abspath

Turning relative paths into ones you can trust

By StableLlama·Created about a year ago·Updated 4 days ago· 48
abspath
    • absolute path
    path

    Relative paths are the enemy of reproducibility. models/loras/foo.safetensors means one thing when ComfyUI is launched from its own directory and something else entirely when it isn't - and because ComfyUI reads "relative" against whatever folder you happened to start the server from, that subtlety bites people constantly. The abspath node from Basic data handling resolves a path into a full, absolute one so you always know exactly what you're pointing at.

    It's the first node you reach for in the pack's Path toolkit, because the other path nodes (basename, dirname, common prefix) are most useful after you've got a canonical absolute path to work with.

    How it works

    A thin wrapper around Python's os.path.abspath(). One input, one output:

    • path - STRING, default empty. Type or wire in any path, relative or absolute.
    • absolute path - STRING output with the fully-resolved path.

    The node collapses . and .. components, prepends the current working directory when the input is relative, and returns a single normalized path string. Give it models/checkpoints/x.safetensors and you get something like C:\ComfyUI\models\checkpoints\x.safetensors (or the /home/you/ComfyUI/... equivalent on Linux).

    The gotchas that actually bite

    • It resolves against the process working directory, which is wherever ComfyUI was started from - usually the ComfyUI root, but not guaranteed if you launch it from elsewhere. So abspath makes a path absolute, not rooted at ComfyUI. If you want a path relative to ComfyUI's own folder regardless of launch location, you want the pack's PathInputDir / PathOutputDir nodes instead, which know about the canonical input/output directories.
    • The README says it resolves symbolic links. It doesn't. The node calls os.path.abspath, which collapses .. but leaves symlinks in place - a symlinked folder stays a symlink. If you specifically need symlinks followed, that's realpath territory, which this node isn't. Harmless 99% of the time, but knowing saves confusion.
    • Empty input resolves to the current working directory itself, so an accidentally-empty path won't error - it'll just silently point at CWD. If that's not what you expected, that's why.

    Where you'd use it

    • Logging or displaying a file path so it's unambiguous.
    • Feeding other path nodes a canonical absolute path before splitting it.
    • Building save paths that survive ComfyUI being launched from any directory.

    Installing it

    Basic data handling is dependency-free with no models to download. ComfyUI Manager → search "Basic data handling" → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart, and abspath is under Basic/Path.

    The take

    If you've ever opened a workflow that wrote files to the wrong folder, you know why this node matters. It's boring, it's tiny, and it removes a whole class of "where did that file go" problems.

    CategoryBasic/Path

    Inputs (1)

    NameTypeDefaultDescription
    pathSTRING

    Outputs (1)

    NameTypeDescription
    absolute pathSTRING