rust-lang/rust · error · Error
No compilation artifacts
Error message
No compilation artifacts
What it means
Thrown by Cargo.executableFromArgs() at toolchain.ts:115-116 when getArtifacts() returns an empty array. getArtifacts() runs cargo with --message-format=json and collects CompilationArtifact entries only for messages where reason is 'compiler-artifact', an executable path is present, and (it's a non-buildscript binary OR a test profile). If zero messages match, no runnable executable was produced.
Source
Thrown at src/tools/rust-analyzer/editors/code/src/toolchain.ts:116
(stderr) => log.error(stderr),
env,
);
} catch (err) {
log.error(`Cargo invocation has failed: ${err}`);
throw new Error(`Cargo invocation has failed: ${err}`, { cause: err });
}
return spec.filter?.(artifacts) ?? artifacts;
}
async executableFromArgs(runnableArgs: CargoRunnableArgs): Promise<string> {
const artifacts = await this.getArtifacts(
Cargo.artifactSpec(runnableArgs.cargoArgs, runnableArgs.executableArgs),
runnableArgs.environment,
);
if (artifacts.length === 0) {
throw new Error("No compilation artifacts");
} else if (artifacts.length > 1) {
throw new Error("Multiple compilation artifacts are not supported.");
}
const artifact = unwrapUndefinable(artifacts[0]);
return artifact.fileName;
}
private async runCargo(
cargoArgs: string[],
onStdoutJson: (obj: CompilerMessage) => void,
onStderrString: (data: string) => void,
env?: Record<string, string>,
): Promise<number> {
const path = await cargoPath(env);
return await new Promise((resolve, reject) => {
const cargo = cp.spawn(path, cargoArgs, {
stdio: ["ignore", "pipe", "pipe"],View on GitHub (pinned to 7088e4b63a)
Solutions
- Verify the target actually produces an executable: run 'cargo build --bin <name>' or 'cargo test --no-run' in the terminal and confirm a binary is emitted.
- If running a test, ensure there are #[test] functions or a [[test]] target in Cargo.toml.
- Check that the cargoArgs passed to executableFromArgs are correct (e.g. 'run' maps to 'build', 'test' needs test artifacts).
- Update rust-analyzer to the latest version if the cargo JSON message format has changed.
Defensive patterns
Strategy: validation
Validate before calling
// Before calling executableFromArgs, verify the target produces an artifact.
// Check Cargo.toml for [[bin]] or [[test]] targets matching the runnable.
function targetProducesBinary(cargoArgs: string[]): boolean {
// 'run'/'build' requires a [[bin]] target; 'test' requires test artifacts
const cmd = cargoArgs[0];
if (cmd === 'run' || cmd === 'build') {
// verify a [[bin]] target exists — caller should parse Cargo.toml
return true; // placeholder for actual check
}
return true;
} Try / catch
try {
const exe = await cargo.executableFromArgs(args);
} catch (e) {
if (e.message === 'No compilation artifacts') {
vscode.window.showWarningMessage(
'This target does not produce a runnable binary. Use a [[bin]] or [[test]] target.'
);
return;
}
throw e;
} Prevention
- Ensure the crate has a [[bin]] target before using the Run code lens.
- For test runnables, confirm #[test] functions or [[test]] targets exist in Cargo.toml.
- Check that the cargoArgs resolve to a target that emits a compiler-artifact with an executable field.
When it happens
Trigger: executableFromArgs() is called when the user invokes a Run/Debug code lens. getArtifacts() returns []. This happens when: the target produces only a library (no bin/test artifact), the artifact filter for 'test'/'bench' specs removes all entries (line 64: result.filter filters by isTest but no test artifacts exist), cargo succeeded but emitted no 'compiler-artifact' message with an executable field, or the crate_type/kind didn't match the bin/test checks at lines 84-92.
Common situations: Clicking Run on a code lens for a library crate that has no binary or test target; running a 'bench' command on a crate without benchmarks; the cargo artifact JSON schema changed and the filter no longer matches; or trying to run an example/bench that produced a different artifact kind.
Related errors
- Cargo invocation has failed: ${err}
- Multiple compilation artifacts are not supported.
- proc-macro-srv-cli needs to be compiled with the `in-rust-tr
- {e:?}: {error}
- rust-analyzer Language Server is not available. Please, ensu
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/e82ce14a96c03272.
Report an issue: GitHub.