nodejs/node · error · GypError

| cannot handle absolute paths, got "%s"

Error message

| cannot handle absolute paths, got "%s"

What it means

GYP's <|(listfile.txt ...) construct writes a list of items to a generated file at gyp-parse time so that overlong input lists can be passed via a response file. The first token inside the parens is treated as the output filename and must be relative to the build file's directory; the parser refuses absolute output paths so generated files stay inside the build tree. If the first token is absolute (os.path.isabs is true) GYP aborts with this GypError before writing anything.

Source

Thrown at tools/gyp/pylib/gyp/input.py:877

            build_file_dir = os.path.dirname(build_file)
            if build_file_dir == "" and not file_list:
                # If build_file is just a leaf filename indicating a file in the
                # current directory, build_file_dir might be an empty string.  Set
                # it to None to signal to subprocess.Popen that it should run the
                # command in the current directory.
                build_file_dir = None

        # Support <|(listfile.txt ...) which generates a file
        # containing items from a gyp list, generated at gyp time.
        # This works around actions/rules which have more inputs than will
        # fit on the command line.
        if file_list:
            contents_list = (
                contents if isinstance(contents, list) else contents.split(" ")
            )
            replacement = contents_list[0]
            if os.path.isabs(replacement):
                raise GypError('| cannot handle absolute paths, got "%s"' % replacement)

            if not generator_filelist_paths:
                path = os.path.join(build_file_dir, replacement)
            else:
                if os.path.isabs(build_file_dir):
                    toplevel = generator_filelist_paths["toplevel"]
                    rel_build_file_dir = gyp.common.RelativePath(
                        build_file_dir, toplevel
                    )
                else:
                    rel_build_file_dir = build_file_dir
                qualified_out_dir = generator_filelist_paths["qualified_out_dir"]
                path = os.path.join(qualified_out_dir, rel_build_file_dir, replacement)
                gyp.common.EnsureDirExists(path)

            replacement = gyp.common.RelativePath(path, build_file_dir)
            f = gyp.common.WriteOnDiff(path)
            for i in contents_list[1:]:

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Make the first token of <|( ... ) a path relative to the .gyp file's own directory (e.g. '<|( gen/listfile.txt ...).
  2. If you need the file under the build output dir, rely on generator_filelist_paths by not forcing an absolute path — let GYP place it via qualified_out_dir.
  3. Check whether an upstream variable (set via -D or in a .gypi include) is injecting an absolute path and rewrite it to be relative.
  4. On Windows, ensure the token is not 'C:\\...' or '\\\\server\\share\\...'; strip the drive/root before passing it in.

Example fix

// before
'action': ['<|( /home/me/build/rsp.txt a b c)'],
// after
'action': ['<|( gen/rsp.txt a b c)'],
Defensive patterns

Strategy: validation

Validate before calling

# Before authoring a <|( ... ) clause, ensure the filename token is relative.
import os
token = filename_token_from_clause  # first item inside the parens
assert not os.path.isabs(token), f"<|() requires a relative path, got {token!r}"

Type guard

def is_relative_response_path(token: str) -> bool:
    return isinstance(token, str) and not os.path.isabs(token)

Prevention

When it happens

Trigger: A .gyp/.gypi file contains an expansion like '<|( /abs/path/listfile.txt a b c)' or '<|( $(rootdir)/out/listfile.txt ...)' where the filename token starts with '/' (POSIX) or a drive root (Windows). It also triggers when a variable expanded into that first token yields an absolute path.

Common situations: Hardcoding an absolute build-output directory in a response-file action; copying a path from a shell that resolves to an absolute path; setting a 'variables' entry to an absolute path and feeding it into a <|(...) filename; cross-platform builds where a Windows path like C:\\tmp\\foo triggers isabs.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/abe7a68fc9cb9b00. Report an issue: GitHub.