{"record":{"id":"1ff2c7e6c54583da","repo":"nodejs/node","slug":"gyp-msvs-override-path-requires-gyp-msvs-version-t","errorCode":null,"errorMessage":"GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be set to a particular version (e.g. 2010e).","messagePattern":"GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be set to a particular version \\(e\\.g\\. 2010e\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/MSVSVersion.py","lineNumber":592,"sourceCode":"        \"2005e\": (\"8.0\",),\n        \"2008\": (\"9.0\",),\n        \"2008e\": (\"9.0\",),\n        \"2010\": (\"10.0\",),\n        \"2010e\": (\"10.0\",),\n        \"2012\": (\"11.0\",),\n        \"2012e\": (\"11.0\",),\n        \"2013\": (\"12.0\",),\n        \"2013e\": (\"12.0\",),\n        \"2015\": (\"14.0\",),\n        \"2017\": (\"15.0\",),\n        \"2019\": (\"16.0\",),\n        \"2022\": (\"17.0\",),\n        \"2026\": (\"18.0\",),\n    }\n    if override_path := os.environ.get(\"GYP_MSVS_OVERRIDE_PATH\"):\n        msvs_version = os.environ.get(\"GYP_MSVS_VERSION\")\n        if not msvs_version:\n            raise ValueError(\n                \"GYP_MSVS_OVERRIDE_PATH requires GYP_MSVS_VERSION to be \"\n                \"set to a particular version (e.g. 2010e).\"\n            )\n        return _CreateVersion(msvs_version, override_path, sdk_based=True)\n    version = str(version)\n    versions = _DetectVisualStudioVersions(version_map[version], \"e\" in version)\n    if not versions:\n        if not allow_fallback:\n            raise ValueError(\"Could not locate Visual Studio installation.\")\n        if version == \"auto\":\n            # Default to 2005 if we couldn't find anything\n            return _CreateVersion(\"2005\", None)\n        else:\n            return _CreateVersion(version, None)\n    return versions[0]\n","sourceCodeStart":574,"sourceCodeEnd":608,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/MSVSVersion.py#L574-L608","documentation":"_GetVisualStudioVersion (in MSVSVersion.py) raises ValueError when the environment variable GYP_MSVS_OVERRIDE_PATH is set but GYP_MSVS_VERSION is not. The override-path mechanism lets you point gyp at a non-standard VS install location, but it requires the version tag (e.g. 2019, 2022, 2026, or an 'e' Express variant) to know which version label to construct. Without it, _CreateVersion cannot be called.","triggerScenarios":"Exporting only GYP_MSVS_OVERRIDE_PATH=/path/to/VS without also exporting GYP_MSVS_VERSION=2022; CI scripts that set the path dynamically but forget the version.","commonSituations":"Custom VS install locations on build agents; redirecting gyp to a portable VS; migrating from hardcoded paths to the override mechanism and missing the second variable.","solutions":["Set both variables together: GYP_MSVS_VERSION=2022 and GYP_MSVS_OVERRIDE_PATH=C:\\Program Files\\Microsoft Visual Studio\\2022\\Community.","Use a version string present in version_map (2022 -> 17.0, 2026 -> 18.0, or an 'e' Express variant).","If you want auto-detection instead, unset GYP_MSVS_OVERRIDE_PATH entirely."],"exampleFix":"# before\nexport GYP_MSVS_OVERRIDE_PATH=/c/VS2022\n\n# after\nexport GYP_MSVS_VERSION=2022\nexport GYP_MSVS_OVERRIDE_PATH=/c/VS2022","handlingStrategy":"validation","validationCode":"import os\noverride = os.environ.get('GYP_MSVS_OVERRIDE_PATH')\nversion = os.environ.get('GYP_MSVS_VERSION')\nif override and not version:\n    raise SystemExit('Set GYP_MSVS_VERSION (e.g. 2022) when using GYP_MSVS_OVERRIDE_PATH.')","typeGuard":"def override_env_is_consistent() -> bool:\n    import os\n    o = os.environ.get('GYP_MSVS_OVERRIDE_PATH')\n    v = os.environ.get('GYP_MSVS_VERSION')\n    return not o or bool(v)","tryCatchPattern":"try:\n    vs = _GetVisualStudioVersion('auto')\nexcept ValueError as e:\n    if 'GYP_MSVS_OVERRIDE_PATH' in str(e):\n        os.environ['GYP_MSVS_VERSION'] = '2022'  # then retry\n        raise","preventionTips":["Always set GYP_MSVS_VERSION alongside GYP_MSVS_OVERRIDE_PATH.","Validate both env vars in a wrapper script before calling gyp.","Prefer a single shell snippet that exports both variables together."],"tags":["gyp","msvs","environment-variables","visual-studio","config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}