nodejs/node · error · Exception

Invalid output_of_set. Value is: %s

Error message

Invalid output_of_set. Value is:
%s

What it means

_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.

Source

Thrown at tools/gyp/pylib/gyp/msvs_emulation.py:1118

def _ExtractImportantEnvironment(output_of_set):
    """Extracts environment variables required for the toolchain to run from
    a textual dump output by the cmd.exe 'set' command."""
    envvars_to_save = (
        "goma_.*",  # TODO(scottmg): This is ugly, but needed for goma.
        "include",
        "lib",
        "libpath",
        "path",
        "pathext",
        "systemroot",
        "temp",
        "tmp",
    )
    env = {}
    # This occasionally happens and leads to misleading SYSTEMROOT error messages
    # if not caught here.
    if output_of_set.count("=") == 0:
        raise Exception("Invalid output_of_set. Value is:\n%s" % output_of_set)
    for line in output_of_set.splitlines():
        for envvar in envvars_to_save:
            if re.match(envvar + "=", line.lower()):
                var, setting = line.split("=", 1)
                if envvar == "path":
                    # Our own rules (for running gyp-win-tool) and other actions in
                    # Chromium rely on python being in the path. Add the path to this
                    # python here so that if it's not in the path when ninja is run
                    # later, python will still be found.
                    setting = os.path.dirname(sys.executable) + os.pathsep + setting
                env[var.upper()] = setting
                break
    for required in ("SYSTEMROOT", "TEMP", "TMP"):
        if required not in env:
            raise Exception(
                'Environment variable "%s" required to be set to valid path' % required
            )
    return env

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Run the exact setup command from the error context manually and inspect its output (it should be VAR=value lines).
  2. Verify the Visual Studio install referenced by GYP_MSVS_VERSION / --msvs_version is present and healthy.
  3. Reinstall or repair the VS Build Tools if the setup script errors out.
  4. Confirm GYP_MSVS_VERSION points to an installed version.

Example fix

// before: env captured an error string
// diagnose:
// $ cmd /c "C:\path\vcvarsall.bat x64 && set"
// after: ensure vcvarsall.bat runs cleanly so set emits VAR=value lines
Defensive patterns

Strategy: validation

Validate before calling

# Reproduce the setup-script capture to fail fast with a clear message.
result = subprocess.run(args, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output = result.stdout.decode('utf-8', 'replace')
if result.returncode != 0:
    raise RuntimeError(f'VS setup failed ({result.returncode}): {output}')
if output.count('=') == 0:
    raise RuntimeError(f'VS setup produced no VAR=value output:\n{output}')

Try / catch

try:
    env = _ExtractImportantEnvironment(output_of_set)
except Exception as e:
    # Surface the raw setup-script output for diagnosis.
    raise RuntimeError(f'failed to parse VS environment; raw output was:\n{output_of_set}') from e

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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