rust-lang/cargo · warning
failed to connect to jobserver from environment variable `{n
Error message
failed to connect to jobserver from environment variable `{name}={value:?}`: {e} What it means
At startup Cargo tries to inherit a make-style jobserver from the environment via jobserver::Client::from_env_ext (mod.rs:324-346). If a jobserver auth var is present but Cargo cannot connect to it (and the error kind is not one of the benign kinds like NoEnvVar/NoJobserver/NegativeFd/Unsupported), it errors 'failed to connect to jobserver from environment variable `<name>=<value>`: <e>'. This typically comes from a malformed MAKEFLAGS/--jobserver-auth. Note: in practice this error is downgraded to a shell warning (the build continues with no inherited jobserver).
Source
Thrown at src/context/mod.rs:342
let jobserver::FromEnv { client, var } =
unsafe { jobserver::Client::from_env_ext(true) };
match client {
Ok(client) => return Ok(Some(client)),
Err(e)
if matches!(
e.kind(),
FromEnvErrorKind::NoEnvVar
| FromEnvErrorKind::NoJobserver
| FromEnvErrorKind::NegativeFd
| FromEnvErrorKind::Unsupported
) =>
{
Ok(None)
}
Err(e) => {
let (name, value) = var.unwrap();
Err(anyhow::anyhow!(
"failed to connect to jobserver from environment variable `{name}={value:?}`: {e}"
))
}
}
},
);
let jobserver = match &*GLOBAL_JOBSERVER {
Ok(jobserver) => jobserver.as_ref(),
Err(e) => {
let _ = shell.warn(e);
None
}
};
let env = Env::new();
let cache_key = "CARGO_CACHE_RUSTC_INFO";
let cache_rustc_info = match env.get_env_os(cache_key) {View on GitHub (pinned to 0e07a15537)
Solutions
- Run cargo directly rather than under make, or use `make`'s `+` recipe marker so the jobserver is properly inherited.
- Unset/strip MAKEFLAGS and CARGO_MAKEFLAGS before invoking cargo if the jobserver cannot be shared.
- Let cargo manage parallelism itself (`-j N`, `build.jobs`).
Example fix
# before (Makefile) build: cargo build # inherits a broken jobserver # after build: +cargo build # '+' lets make share the jobserver correctly
Defensive patterns
Strategy: validation
Validate before calling
# Detect a jobserver that cannot be inherited before running cargo: if [ -n "$MAKEFLAGS" ] && ! [ -t 1 ]; then # likely spawned under make; prefer make's '+' marker or strip flags: unset MAKEFLAGS fi cargo build
Prevention
- Use `make`'s `+` recipe marker when invoking cargo from make so the jobserver is shared correctly.
- Do not forward MAKEFLAGS across exec/container boundaries that cannot share FDs.
- Let cargo manage its own parallelism via -j / build.jobs when in doubt.
When it happens
Trigger: Running cargo under `make -jN` (which sets MAKEFLAGS with --jobserver-auth=fifo:/path or =client,server FDs) where the FIFO/FDs are invalid, closed, or not actually a valid jobserver; forwarding a stale MAKEFLAGS into a container/child that lacks the FDs.
Common situations: CI that exports MAKEFLAGS across process boundaries that cannot share the FDs; a wrapper that fabricates --jobserver-auth; running cargo inside `make` after the make jobserver FDs were closed.
Related errors
- no executable for `{}` found in PATH
- jobs may not be 0
- could not parse `{j}`. Number of parallel jobs should be `de
- {key:?} could not be found in the environment snapshot
- Cargo couldn't find your home directory. This probably means
AI-assisted analysis of rust-lang/cargo@0e07a15537 (2026-08-06).
Data as JSON: /data/errors/a72153de3d1abd8b.json.
Report an issue: GitHub.