{"record":{"id":"79041acf8f9a18c0","repo":"rust-lang/cargo","slug":"could-not-parse-j-number-of-parallel-jobs-sho","errorCode":null,"errorMessage":"could not parse `{j}`. Number of parallel jobs should be `default` or a number.","messagePattern":"could not parse `(.+?)`\\. Number of parallel jobs should be `default` or a number\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/build_config.rs","lineNumber":97,"sourceCode":"        if jobs.is_some() && gctx.jobserver_from_env().is_some() {\n            gctx.shell().warn(\n                \"a `-j` argument was passed to Cargo but Cargo is \\\n                 also configured with an external jobserver in \\\n                 its environment, ignoring the `-j` parameter\",\n            )?;\n        }\n        let jobs = match jobs.or(cfg.jobs.clone()) {\n            None => default_parallelism()?,\n            Some(value) => match value {\n                JobsConfig::Integer(j) => match j {\n                    0 => anyhow::bail!(\"jobs may not be 0\"),\n                    j if j < 0 => (default_parallelism()? as i32 + j).max(1) as u32,\n                    j => j as u32,\n                },\n                JobsConfig::String(j) => match j.as_str() {\n                    \"default\" => default_parallelism()?,\n                    _ => {\n                        anyhow::bail!(format!(\n                            \"could not parse `{j}`. Number of parallel jobs should be `default` or a number.\"\n                        ))\n                    }\n                },\n            },\n        };\n\n        // If sbom flag is set, it requires the unstable feature\n        let sbom = match (cfg.sbom, gctx.cli_unstable().sbom) {\n            (Some(sbom), true) => sbom,\n            (Some(_), false) => {\n                gctx.shell()\n                    .warn(\"ignoring 'sbom' config, pass `-Zsbom` to enable it\")?;\n                false\n            }\n            (None, _) => false,\n        };\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/compiler/build_config.rs#L79-L115","documentation":"Cargo failed to parse the `jobs` setting (configures build parallelism via `build.jobs` or `--jobs`). The value was a string that was neither the literal `\"default\"` nor parseable as an integer. Cargo accepts only `JobsConfig::Integer` or the string `\"default\"`; any other string falls through to this bail.","triggerScenarios":"Setting `build.jobs = \"auto\"` (or `\"max\"`, `\"all\"`, `\"8\"` as a quoted string that isn't the literal `default`) in config, or passing `--jobs foo` / `CARGO_BUILD_JOBS=foo`. Also triggered by a TOML config that stores jobs as a non-integer, non-`default` string.","commonSituations":"Users assume Cargo understands words like `auto`/`max`/`unlimited`; misconfigured CI templates that set `CARGO_BUILD_JOBS=\"${N}\"` with an empty or non-numeric N; YAML-to-TOML migrations that quote numbers.","solutions":["Set `build.jobs` to an integer (e.g. `jobs = 4`) or the literal string `default` in `.cargo/config.toml`.","If using an env var, ensure `CARGO_BUILD_JOBS` holds a plain integer or omit it to use default parallelism.","Pass `--jobs N` (integer) or `--jobs default` on the command line.","Audit shell scripts that interpolate `${JOBS}` and guard against empty/non-numeric values before exporting."],"exampleFix":"// before (config.toml)\n[build]\njobs = \"auto\"\n\n// after\n[build]\njobs = \"default\"\n// or\njobs = 4","handlingStrategy":"validation","validationCode":"// Validate a jobs value before handing it to Cargo config\nfn is_valid_jobs(v: &str) -> bool {\n    v == \"default\" || v.parse::<i32>().map(|n| n != 0).unwrap_or(false)\n}","typeGuard":"fn is_jobs_string(v: &str) -> bool { v == \"default\" }\nfn is_jobs_int(v: &serde_json::Value) -> bool { v.is_i64() && v.as_i64().map(|n| n != 0).unwrap_or(false) }","tryCatchPattern":"match cargo::BuildConfig::from_env() {\n    Ok(cfg) => cfg,\n    Err(e) if e.to_string().contains(\"could not parse\") => { eprintln!(\"jobs must be `default` or an integer\"); default_config() },\n    Err(e) => return Err(e),\n}","preventionTips":["Always store `build.jobs` as a bare TOML integer or the literal string `default`.","In shell scripts, default `CARGO_BUILD_JOBS` to empty rather than a placeholder word.","Unit-test config generators that emit the jobs value."],"tags":["cargo","config","parallelism","build-config"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}