(chromeBinaryPath: string)
| 255 | * "inconclusive" rather than "missing". |
| 256 | */ |
| 257 | export function probeChromeSharedLibs(chromeBinaryPath: string): SharedLibProbeResult { |
| 258 | if (process.platform !== "linux") { |
| 259 | return { ok: true, missing: [], probeUnavailable: true }; |
| 260 | } |
| 261 | if (!existsSync(chromeBinaryPath)) { |
| 262 | return { ok: true, missing: [], probeUnavailable: true }; |
| 263 | } |
| 264 | let output: string; |
| 265 | try { |
| 266 | // ldd exits non-zero when libs are missing but still prints the resolution |
| 267 | // table to stdout, so capture stdout even on failure. |
| 268 | output = execFileSync("ldd", [chromeBinaryPath], { |
| 269 | encoding: "utf-8", |
| 270 | timeout: 5000, |
| 271 | }); |
| 272 | } catch (err) { |
| 273 | // A timed-out/killed ldd leaves only a partial resolution table, which we |
| 274 | // must NOT parse as authoritative (would report spurious missing libs). |
| 275 | // Anything other than a clean non-zero exit with full stdout is |
| 276 | // inconclusive. |
| 277 | if (isKilledExecError(err)) { |
| 278 | return { ok: true, missing: [], probeUnavailable: true }; |
| 279 | } |
| 280 | const stdout = execErrorStdout(err); |
| 281 | if (stdout == null) { |
| 282 | // `ldd` not installed / not executable — we cannot conclude anything. |
| 283 | return { ok: true, missing: [], probeUnavailable: true }; |
| 284 | } |
| 285 | output = stdout; |
| 286 | } |
| 287 | return parseLddMissingLibs(output); |
| 288 | } |
| 289 | |
| 290 | /** |
| 291 | * Parse `ldd` output into the set of unresolved libraries. Exported so the |
no test coverage detected