{"record":{"id":"68f3cd8c57c09780","repo":"cube-js/cube","slug":"unable-to-detect-libc-on-not-linux-os","errorCode":null,"errorMessage":"Unable to detect libc on not linux os","messagePattern":"Unable to detect libc on not linux os","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-backend-shared/src/platform.ts","lineNumber":8,"sourceCode":"import { spawnSync } from 'child_process';\nimport process from 'process';\nimport { internalExceptions } from './errors';\nimport { displayCLIWarning, displayCLIWarningOnce } from './cli';\n\nexport function detectLibc() {\n  if (process.platform !== 'linux') {\n    throw new Error('Unable to detect libc on not linux os');\n  }\n\n  try {\n    const { status } = spawnSync('getconf', ['GNU_LIBC_VERSION'], {\n      encoding: 'utf8',\n      // Using pipe to protect unexpect STDERR output\n      stdio: 'pipe'\n    });\n    if (status === 0) {\n      return 'gnu';\n    }\n  } catch (e: any) {\n    internalExceptions(e);\n  }\n\n  {\n    const { status, stdout, stderr } = spawnSync('ldd', ['--version'], {\n      encoding: 'utf8',","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-backend-shared/src/platform.ts#L1-L26","documentation":"detectLibc() is a Linux-only helper that runs `getconf GNU_LIBC_VERSION` to determine whether the system uses glibc (e.g. Debian/Ubuntu) or musl (e.g. Alpine). It throws this error immediately when process.platform is not 'linux', because libc detection is meaningless on other operating systems. Callers like isNativeSupported, getTarget, and isCubeStoreSupported use it to pick native binaries (CubeStore), so it is only meant to be invoked on Linux.","triggerScenarios":"Calling detectLibc() (directly or via isNativeSupported/getTarget/isCubeStoreSupported) while running on macOS, Windows, or another non-Linux platform; e.g. checking CubeStore native support inside a macOS dev script that assumes Linux.","commonSituations":"A cross-platform build or setup script calls Cube native-support checks on a developer's Mac or Windows machine; CI matrix accidentally runs a Linux-only detection step on a Windows runner; code written for a Linux deployment image is executed locally without a platform guard.","solutions":["Guard the call: only invoke detectLibc()/isNativeSupported()/isCubeStoreSupported() when process.platform === 'linux'.","Use the higher-level platform helpers (isNativeSupported/getTarget) which branch on OS themselves instead of calling detectLibc directly.","Run the code inside Linux (Docker container, Linux CI runner) if Linux-native behavior is required.","Wrap in try/catch and fall back to a non-native (e.g. dockerized CubeStore) path when detection is unavailable."],"exampleFix":"// before\nconst supported = isCubeStoreSupported();\n// after\nconst supported = process.platform === 'linux' && isCubeStoreSupported();","handlingStrategy":"fallback","validationCode":"// check platform before invoking Linux-only detection\nif (process.platform !== 'linux') {\n  // skip native libc detection / use non-native path\n}","typeGuard":"const isLinux = (): boolean => process.platform === 'linux';","tryCatchPattern":"let supported = false;\ntry {\n  supported = isCubeStoreSupported();\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Unable to detect libc')) supported = false;\n  else throw e;\n}","preventionTips":["Never call detectLibc() outside a process.platform === 'linux' branch.","Prefer the higher-level isNativeSupported()/getTarget() helpers over direct libc detection.","Test cross-platform scripts on macOS/Windows or in a Linux container.","Design native-binary checks to fall back to dockerized/non-native modes."],"tags":["platform","linux","native-binaries","cube-store"],"backgroundTag":"unsupported-platform","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}