{"record":{"id":"dd036b6831a0ad1b","repo":"nodejs/node","slug":"the-working-directory-for-run-as-in-target-s","errorCode":null,"errorMessage":"The 'working_directory' for 'run_as' in target %s in file %s should be a string.","messagePattern":"The 'working_directory' for 'run_as' in target (.+?) in file (.+?) should be a string\\.","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":2793,"sourceCode":"    if not isinstance(run_as, dict):\n        raise GypError(\n            \"The 'run_as' in target %s from file %s should be a \"\n            \"dictionary.\" % (target_name, build_file)\n        )\n    action = run_as.get(\"action\")\n    if not action:\n        raise GypError(\n            \"The 'run_as' in target %s from file %s must have an \"\n            \"'action' section.\" % (target_name, build_file)\n        )\n    if not isinstance(action, list):\n        raise GypError(\n            \"The 'action' for 'run_as' in target %s from file %s \"\n            \"must be a list.\" % (target_name, build_file)\n        )\n    working_directory = run_as.get(\"working_directory\")\n    if working_directory and not isinstance(working_directory, str):\n        raise GypError(\n            \"The 'working_directory' for 'run_as' in target %s \"\n            \"in file %s should be a string.\" % (target_name, build_file)\n        )\n    environment = run_as.get(\"environment\")\n    if environment and not isinstance(environment, dict):\n        raise GypError(\n            \"The 'environment' for 'run_as' in target %s \"\n            \"in file %s should be a dictionary.\" % (target_name, build_file)\n        )\n\n\ndef ValidateActionsInTarget(target, target_dict, build_file):\n    \"\"\"Validates the inputs to the actions in a target.\"\"\"\n    target_name = target_dict.get(\"target_name\")\n    actions = target_dict.get(\"actions\", [])\n    for action in actions:\n        action_name = action.get(\"action_name\")\n        if not action_name:","sourceCodeStart":2775,"sourceCodeEnd":2811,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L2775-L2811","documentation":"The optional 'working_directory' under run_as must be a string path. Any other truthy type is rejected before it is handed to the build tooling that changes into that directory before running the action.","triggerScenarios":"run_as['working_directory'] is truthy but isinstance(working_directory, str) is False.","commonSituations":"Setting working_directory to a list (e.g. a gyp list expansion that produced multiple values) or to a dict; a variable expansion that resolved to a non-string object.","solutions":["Make working_directory a single string path (typically a gyp variable expansion like '<(PRODUCT_DIR)').","If a list expansion caused it, fix the variable so it yields one path string.","Re-run gyp."],"exampleFix":"// before\n'run_as': { 'action': ['app'], 'working_directory': ['<(PRODUCT_DIR)'] },\n// after\n'run_as': { 'action': ['app'], 'working_directory': '<(PRODUCT_DIR)' },","handlingStrategy":"type-guard","validationCode":"ra = target_dict.get('run_as')\nif isinstance(ra, dict):\n    wd = ra.get('working_directory')\n    if wd and not isinstance(wd, str):\n        raise TypeError('run_as.working_directory must be a string')","typeGuard":"def run_as_wd_is_str(target_dict: dict) -> bool:\n    ra = target_dict.get('run_as')\n    if not isinstance(ra, dict):\n        return True\n    wd = ra.get('working_directory')\n    return wd is None or isinstance(wd, str)","tryCatchPattern":null,"preventionTips":["Use a single gyp path variable for working_directory.","Avoid list expansions for paths."],"tags":["gyp","run-as","working-directory","type","validation"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}