{"record":{"id":"ddb0f088421aa668","repo":"nodejs/node","slug":"invalid-output-of-set-value-is-s","errorCode":null,"errorMessage":"Invalid output_of_set. Value is:\n%s","messagePattern":"Invalid output_of_set\\. Value is:\n(.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/msvs_emulation.py","lineNumber":1118,"sourceCode":"def _ExtractImportantEnvironment(output_of_set):\n    \"\"\"Extracts environment variables required for the toolchain to run from\n    a textual dump output by the cmd.exe 'set' command.\"\"\"\n    envvars_to_save = (\n        \"goma_.*\",  # TODO(scottmg): This is ugly, but needed for goma.\n        \"include\",\n        \"lib\",\n        \"libpath\",\n        \"path\",\n        \"pathext\",\n        \"systemroot\",\n        \"temp\",\n        \"tmp\",\n    )\n    env = {}\n    # This occasionally happens and leads to misleading SYSTEMROOT error messages\n    # if not caught here.\n    if output_of_set.count(\"=\") == 0:\n        raise Exception(\"Invalid output_of_set. Value is:\\n%s\" % output_of_set)\n    for line in output_of_set.splitlines():\n        for envvar in envvars_to_save:\n            if re.match(envvar + \"=\", line.lower()):\n                var, setting = line.split(\"=\", 1)\n                if envvar == \"path\":\n                    # Our own rules (for running gyp-win-tool) and other actions in\n                    # Chromium rely on python being in the path. Add the path to this\n                    # python here so that if it's not in the path when ninja is run\n                    # later, python will still be found.\n                    setting = os.path.dirname(sys.executable) + os.pathsep + setting\n                env[var.upper()] = setting\n                break\n    for required in (\"SYSTEMROOT\", \"TEMP\", \"TMP\"):\n        if required not in env:\n            raise Exception(\n                'Environment variable \"%s\" required to be set to valid path' % required\n            )\n    return env","sourceCodeStart":1100,"sourceCodeEnd":1136,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/msvs_emulation.py#L1100-L1136","documentation":"_ExtractImportantEnvironment parses the textual output of a Windows 'set' command (run via the VS setup script). If that output contains no '=' at all, the string is not a valid environment block and parsing would silently produce an empty dict, leading to confusing downstream errors about SYSTEMROOT. So gyp raises early with the raw value for diagnosis.","triggerScenarios":"vs.SetupScript is run, then '&& set' is appended, and the captured stdout (output_of_set) contains zero '=' characters — e.g. the script printed an error message instead of VAR=value lines.","commonSituations":"The VS setup batch printed an error or path-missing message before reaching 'set'; a corrupt/aborted VS installation; locale or encoding issue mangling the output; calling gyp with an msvs_version that points at a non-existent toolchain.","solutions":["Run the exact setup command from the error context manually and inspect its output (it should be VAR=value lines).","Verify the Visual Studio install referenced by GYP_MSVS_VERSION / --msvs_version is present and healthy.","Reinstall or repair the VS Build Tools if the setup script errors out.","Confirm GYP_MSVS_VERSION points to an installed version."],"exampleFix":"// before: env captured an error string\n// diagnose:\n// $ cmd /c \"C:\\path\\vcvarsall.bat x64 && set\"\n// after: ensure vcvarsall.bat runs cleanly so set emits VAR=value lines","handlingStrategy":"validation","validationCode":"# Reproduce the setup-script capture to fail fast with a clear message.\nresult = subprocess.run(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\noutput = result.stdout.decode('utf-8', 'replace')\nif result.returncode != 0:\n    raise RuntimeError(f'VS setup failed ({result.returncode}): {output}')\nif output.count('=') == 0:\n    raise RuntimeError(f'VS setup produced no VAR=value output:\\n{output}')","typeGuard":null,"tryCatchPattern":"try:\n    env = _ExtractImportantEnvironment(output_of_set)\nexcept Exception as e:\n    # Surface the raw setup-script output for diagnosis.\n    raise RuntimeError(f'failed to parse VS environment; raw output was:\\n{output_of_set}') from e","preventionTips":["Always verify the VS toolchain install before running gyp on Windows.","Run vcvarsall.bat manually first to confirm it emits VAR=value lines.","Pin a known-good GYP_MSVS_VERSION."],"tags":["gyp","msvs","environment","setup"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}