{"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/0e07a155371a6ce88ae53a2c00df940280c09a67/src/compiler/build_config.rs#L79-L115","documentation":"In BuildConfig::new (build_config.rs:94-100), `jobs` can be the string `\"default\"` or an integer. If `build.jobs` (or `-j`) is set to any other string (e.g. `\"auto\"`, `\"max\"`, `\"4 cores\"`), parsing fails with `could not parse ... Number of parallel jobs should be 'default' or a number`.","triggerScenarios":"Setting `[build] jobs = \"auto\"` in config, passing `cargo build -j auto`, or setting `CARGO_BUILD_JOBS=auto`.","commonSituations":"Users assuming Cargo accepts `auto`/`max`/`physical` (common in other tools); copying config from make/ninja; stale docs.","solutions":["Use an integer: `cargo build -j 8` or `[build] jobs = 8`.","Use the literal string `default` to use the default parallelism.","Remove the `jobs` setting to fall back to default parallelism.","If you wanted `auto`, just omit `-j`."],"exampleFix":"// before (.cargo/config.toml)\n[build]\njobs = \"auto\"\n\n// after\n[build]\njobs = \"default\"","handlingStrategy":"validation","validationCode":"match &jobs_config {\n    JobsConfig::String(s) if s != \"default\" => {\n        return Err(format!(\"jobs `{s}` must be a number or `default`\"));\n    }\n    _ => {}\n}","typeGuard":"fn jobs_string_valid(s: &str) -> bool {\n    s == \"default\" || s.parse::<i64>().is_ok()\n}\n","tryCatchPattern":null,"preventionTips":["Constrain build.jobs config to integers or the literal \"default\".","Reject unknown aliases like \"auto\" in config-lint CI."],"tags":["cargo","build","parallelism","config","argument"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}