{"record":{"id":"23cb1303a4c9213e","repo":"jdx/mise","slug":"cache-agent-did-not-return-the-rustc-identity","errorCode":null,"errorMessage":"cache agent did not return the rustc identity","messagePattern":"cache agent did not return the rustc identity","errorType":"exception","errorClass":"eyre::Report","httpStatus":null,"severity":"error","filePath":"src/cache/rustc.rs","lineNumber":585,"sourceCode":"    }\n    if !expected.is_empty() {\n        bail!(\"cached rustc output set is incomplete\");\n    }\n    Ok(files)\n}\n\nfn compiler_identity(rustc: &OsStr) -> Result<CompilerIdentity> {\n    let executable = resolve_executable(rustc)?;\n    let environment = [\"RUSTUP_HOME\", \"RUSTUP_TOOLCHAIN\"]\n        .into_iter()\n        .map(|name| (name.into(), std::env::var(name).ok()))\n        .collect::<BTreeMap<_, _>>();\n    let responses = session::request_agent(&[AgentRequest::FindExecutableIdentity {\n        executable: executable.clone(),\n        environment: environment.clone(),\n    }])?;\n    let Some(AgentResponse::ExecutableIdentity { stdout }) = responses.into_iter().next() else {\n        bail!(\"cache agent did not return the rustc identity\");\n    };\n    let stdout = if let Some(stdout) = stdout {\n        stdout\n    } else {\n        let mut command = Command::new(&executable);\n        command.arg(\"-vV\");\n        for (name, value) in &environment {\n            if let Some(value) = value {\n                command.env(name, value);\n            } else {\n                command.env_remove(name);\n            }\n        }\n        let output = command\n            .output()\n            .wrap_err(\"failed to query the rustc identity\")?;\n        if !output.status.success() {\n            bail!(","sourceCodeStart":567,"sourceCodeEnd":603,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/cache/rustc.rs#L567-L603","documentation":"compiler_identity() asks the session agent for the cached 'rustc -vV' output via FindExecutableIdentity, keyed on the resolved executable plus RUSTUP_HOME/RUSTUP_TOOLCHAIN (src/cache/rustc.rs:574-586). If the first response is absent or not an ExecutableIdentity variant, the shim throws: the agent protocol exchange is broken. This is distinct from a mere identity miss, which is ExececutableIdentity { stdout: None } and triggers a local 'rustc -vV' run instead.","triggerScenarios":"Response-stream skew (a different AgentResponse variant answered the request), a stale MISE_CACHE_SOCKET pointing at an agent from another mise build, or an agent bug; the error aborts the cache context build (base_action_context), so the invocation degrades to prediction lookup or a plain compile.","commonSituations":"Inherited MISE_CACHE_* environment from an older session; two mise versions sharing a session dir; wrapping the shim in another tool that strips or reorders the agent socket env.","solutions":["Restart the mise task/session so the shim talks to the agent spawned by the same mise binary","Unset inherited MISE_CACHE_* variables in shell profiles and CI images","Confirm mise versions match inside and outside the task","Verify nothing strips MISE_CACHE_SOCKET from the task environment"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# confirm a live agent of the current session before relying on the cache:\ntest -S \"$MISE_CACHE_SOCKET\" || echo 'run inside a mise task with rust cache enabled'","typeGuard":"fn is_identity_response(r: &AgentResponse) -> bool {\n    matches!(r, AgentResponse::ExecutableIdentity { .. })\n}","tryCatchPattern":null,"preventionTips":["Do not strip or reorder MISE_CACHE_* variables when wrapping mise tasks in other tools","Keep shim and agent from the same mise binary — avoid stale session sockets","On identity errors, let the shim degrade to a plain compile; only investigate wiring if warnings persist"],"tags":["rust","cache","agent","protocol","rustc"],"backgroundTag":"agent-protocol-mismatch","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}