{"record":{"id":"e910e449c0947422","repo":"nodejs/node","slug":"unsupported-host-platform-sys-platform-r","errorCode":null,"errorMessage":"Unsupported host platform {sys.platform!r}","messagePattern":"Unsupported host platform (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deps/libffi/generate-headers.py","lineNumber":216,"sourceCode":"        encoding='utf-8')\n    (output_dir / 'fficonfig.h').write_text(\n        render_fficonfig(os_name, target_arch),\n        encoding='utf-8')\n    (output_dir / 'ffitarget.h').write_text(\n        ffitarget_src.read_text(encoding='utf-8'),\n        encoding='utf-8')\n\n\ndef detect_os_name():\n    if sys.platform.startswith('win'):\n        return 'win'\n    if sys.platform == 'darwin':\n        return 'mac'\n    if sys.platform.startswith('linux'):\n        return 'linux'\n    if sys.platform.startswith('freebsd'):\n        return 'freebsd'\n    raise ValueError(f'Unsupported host platform {sys.platform!r}')\n\n\ndef detect_target_arch():\n    candidates = [\n        os.environ.get('TARGET_ARCH'),\n        os.environ.get('npm_config_arch'),\n        os.environ.get('VSCMD_ARG_TGT_ARCH'),\n        os.environ.get('Platform'),\n        os.environ.get('PROCESSOR_ARCHITECTURE'),\n        platform.machine(),\n    ]\n\n    aliases = {\n        'amd64': 'x64',\n        'x86_64': 'x64',\n        'x64': 'x64',\n        'win32': 'x64',\n        'i386': 'ia32',","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/libffi/generate-headers.py#L198-L234","documentation":"detect_os_name() narrows sys.platform to one of win/mac/linux/freebsd so the rest of generate-headers.py can pick the right libffi platform branch. Anything else (aix, solaris, cygwin, emscripten, etc.) falls through and is rejected, because no header-generation path exists for it.","triggerScenarios":"Raised at the end of detect_os_name() when sys.platform doesn't start with 'win', equal 'darwin', start with 'linux', or start with 'freebsd'. Only fires when --os is not passed on the CLI and the host must be auto-detected.","commonSituations":"Building on AIX, Solaris/illumos, Haiku, or under emscripten/wasi where sys.platform is something unexpected; outdated Python reporting a non-standard platform string; CI on niche OSes.","solutions":["Pass --os explicitly (win|mac|linux|freebsd) to bypass host detection when you know the target.","If you're genuinely on a 4th-class platform, extend detect_os_name() and add the matching get_target()/has_long_double() branches.","Run under a supported container/host if you only need the headers generated."],"exampleFix":"# before: host is aix, auto-detect fails\npython generate-headers.py --output-dir out --target-arch ppc64\n# after\npython generate-headers.py --output-dir out --target-arch ppc64 --os linux","handlingStrategy":"validation","validationCode":"import sys\nKNOWN = ('win','mac','linux','freebsd')\nos_name = args.os or ('win' if sys.platform.startswith('win') else\n                    'mac' if sys.platform=='darwin' else\n                    'linux' if sys.platform.startswith('linux') else\n                    'freebsd' if sys.platform.startswith('freebsd') else None)\nassert os_name in KNOWN, f'unsupported host {sys.platform!r}; pass --os explicitly'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --os explicitly in CI instead of relying on host detection.","Document the four supported os values in your build README."],"tags":["libffi","build","ffi","platform","host-detect"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}