nodejs/node · error · ValueError
Can't use path {path} in a {self.__class__.__name__}
Error message
Can't use path {path} in a {self.__class__.__name__} What it means
Raised by the path-parsing logic in a PBXCopyFilesBuildPhase (copy-files / resources copy phase) when a destination path does not match any recognized pattern: it is not an absolute path (starting with '/'), does not start with a known Xcode variable like $(DEVELOPER_RESOURCES), $(HOME), $(SDKROOT), $(SRCROOT), or $(BUILT_PRODUCTS_DIR). A bare relative path is not valid for a copy-files destination, so the code raises ValueError rather than silently misplacing the file.
Source
Thrown at tools/gyp/pylib/gyp/xcodeproj_file.py:2179
)
else:
# subfolder = 16 from above
# The second element of the path is an unrecognized variable.
# Include it and any remaining elements in relative_path.
relative_path = path_tree_match.group(3)
else:
# The path starts with an unrecognized Xcode variable
# name like $(SRCROOT). Xcode will still handle this
# as an "absolute path" that starts with the variable.
subfolder = 0
relative_path = path
elif path.startswith("/"):
# Special case. Absolute paths are in dstSubfolderSpec 0.
subfolder = 0
relative_path = path[1:]
else:
raise ValueError(f"Can't use path {path} in a {self.__class__.__name__}")
self._properties["dstPath"] = relative_path
self._properties["dstSubfolderSpec"] = subfolder
class PBXBuildRule(XCObject):
_schema = XCObject._schema.copy()
_schema.update(
{
"compilerSpec": [0, str, 0, 1],
"filePatterns": [0, str, 0, 0],
"fileType": [0, str, 0, 1],
"isEditable": [0, int, 0, 1, 1],
"outputFiles": [1, str, 0, 1, []],
"script": [0, str, 0, 0],
}
)
View on GitHub (pinned to 1b2de5e052)
Solutions
- Use an absolute path or a recognized Xcode variable: $(SRCROOT), $(BUILT_PRODUCTS_DIR), $(HOME), $(SDKROOT), $(DEVELOPER_RESOURCES).
- Prefix the path with $(SRCROOT)/ to anchor a source-tree-relative destination.
- Check variable syntax: Xcode uses $(VAR_NAME) form, not $VAR_NAME.
- For copy resources into the bundle, prefer $(BUILT_PRODUCTS_DIR)/$(CONTENTS_FOLDER_PATH).
Example fix
# before 'destination_path': 'Resources/icons' # after 'destination_path': '$(SRCROOT)/Resources/icons'
Defensive patterns
Strategy: validation
Validate before calling
# Validate copy-files destination path before assignment
import re
_RECOGNIZED = re.compile(r'^(/|\$\((SRCROOT|BUILT_PRODUCTS_DIR|HOME|SDKROOT|DEVELOPER_RESOURCES|CONTENTS_FOLDER_PATH)\))')
if not _RECOGNIZED.match(path):
path = '$(SRCROOT)/' + path # anchor relative paths Prevention
- Always anchor copy-files destination paths with $(SRCROOT) or another Xcode variable.
- Use $(VAR) syntax, not $VAR, for Xcode build variables.
When it happens
Trigger: SetDstPath or equivalent is called with a relative path string like 'subdir/file' or 'foo' that doesn't begin with '/' or a recognized $(...) variable prefix. The path falls through all the elif branches to the final else.
Common situations: Specifying a relative destination path for a copy-files build phase in gyp config. Using a non-standard Xcode variable name. A typo in the variable syntax (e.g. '$SRCROOT' instead of '$(SRCROOT)').
Related errors
- Found multiple children with path ${child_path}
- Found multiple PBXVariantGroup children with name ${child_na
- Found multiple build files with path ${path}
- Found multiple build files for ${name}
- ninja not found in PATH
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/ff05db291c1d1acf.
Report an issue: GitHub.