{"record":{"id":"6c10eac7322461e4","repo":"rust-lang/rust","slug":"failed-to-execute-path-version","errorCode":null,"errorMessage":"Failed to execute ${path} --version.","messagePattern":"Failed to execute (.+?) --version\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/tools/rust-analyzer/editors/code/src/bootstrap.ts","lineNumber":25,"sourceCode":"import { TextDecoder } from \"node:util\";\n\nexport async function bootstrap(\n    context: vscode.ExtensionContext,\n    config: Config,\n    state: PersistentState,\n): Promise<string> {\n    const path = await getServer(context, config, state);\n    if (!path) {\n        throw new Error(\n            \"rust-analyzer Language Server is not available. \" +\n                \"Please, ensure its [proper installation](https://rust-analyzer.github.io/book/installation.html).\",\n        );\n    }\n\n    log.info(\"Using server binary at\", path);\n\n    if (!isValidExecutable(path, config.serverExtraEnv)) {\n        throw new Error(\n            `Failed to execute ${path} --version.` +\n                (config.serverPath\n                    ? `\\`config.server.path\\` or \\`config.serverPath\\` has been set explicitly.\\\n            Consider removing this config or making a valid server binary available at that path.`\n                    : \"\"),\n        );\n    }\n\n    return path;\n}\nasync function getServer(\n    context: vscode.ExtensionContext,\n    config: Config,\n    state: PersistentState,\n): Promise<string | undefined> {\n    const packageJson: {\n        version: string;\n        releaseTag: string | null;","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/rust-analyzer/editors/code/src/bootstrap.ts#L7-L43","documentation":"Thrown by bootstrap() at line 24-31 after isValidExecutable() returns false. isValidExecutable() spawns the resolved server binary with ['--version'] using the merged process + serverExtraEnv, and returns true only when the child exits with status 0. A false return means the binary was found but could not be executed successfully. When serverPath was explicitly set, the error appends guidance to remove or fix that config.","triggerScenarios":"isValidExecutable(path, config.serverExtraEnv) returns false at bootstrap.ts:24. Specifically: spawnAsync(path, ['--version'], {env}) at line 213 returns a result whose res.status !== 0 (line 222). This covers: the binary exists but is not executable (permissions), has an incompatible architecture (e.g. x86 binary on ARM), has missing shared libraries, is a Windows .exe on Linux or vice versa, or the --version invocation crashes/exits non-zero.","commonSituations":"Configuring serverPath to a binary built for a different OS/arch; missing execute permission bit after a manual copy; corrupted or partially-built binary; mismatched dynamic linker (especially on non-NixOS systems with custom lib paths); a stale serverPath pointing at an old or broken build after an upgrade.","solutions":["Run the resolved path manually in a terminal: '/path/to/rust-analyzer --version' to see the actual OS-level error (missing .so, permission denied, exec format error).","Fix execute permissions: 'chmod +x /path/to/rust-analyzer'.","If the binary is the wrong architecture, reinstall or rebuild it for the host platform (rustup component add rust-analyzer, or rustup update).","Remove the explicit 'rust-analyzer.server.path' setting so the extension falls back to its bundled or PATH-resolved binary.","Check serverExtraEnv settings for environment variables that break the binary's runtime (e.g. LD_LIBRARY_PATH pointing at wrong libs)."],"exampleFix":"// before: serverPath points at a broken/wrong-arch binary\n// settings.json\n{ \"rust-analyzer.server.path\": \"/home/user/old-build/ra\" }\n// after: remove the setting to use bundled binary\n// (delete the key) or\n{ \"rust-analyzer.server.path\": \"/home/user/.cargo/bin/rust-analyzer\" }","handlingStrategy":"validation","validationCode":"import { isValidExecutable } from './bootstrap';\n\n// Pre-check before relying on a server path\nconst valid = await isValidExecutable(candidatePath, config.serverExtraEnv);\nif (!valid) {\n  // Show actionable guidance before bootstrap throws\n  vscode.window.showWarningMessage(\n    `rust-analyzer binary at ${candidatePath} is not executable. Check permissions and architecture.`\n  );\n}","typeGuard":null,"tryCatchPattern":"try {\n  const serverPath = await bootstrap(context, config, state);\n  // proceed\n} catch (e) {\n  if (e.message.includes('Failed to execute') && e.message.includes('--version')) {\n    // Specific: binary found but won't run\n    log.error('Server binary exists but is not executable/compatible', e);\n  }\n  throw e;\n}","preventionTips":["After setting serverPath, test it manually: run the binary with --version in a terminal.","Ensure the binary has execute permission (chmod +x).","Verify the binary matches the host architecture (uname -m vs file <binary>).","Keep serverExtraEnv minimal — avoid LD_LIBRARY_PATH or DYLD_* overrides unless necessary."],"tags":["rust-analyzer","vscode-extension","executable","binary-validation","configuration"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}