{"record":{"id":"600b46e416f6a1b8","repo":"BoundaryML/baml","slug":"usage-baml-replace-tmp-current","errorCode":null,"errorMessage":"usage: baml --replace <tmp> <current>","messagePattern":"usage: baml --replace <tmp> <current>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml/src/main.rs","lineNumber":1609,"sourceCode":"}\n\n#[cfg(all(feature = \"self-update\", not(feature = \"no-self-update\")))]\nfn http_client() -> Result<reqwest::blocking::Client> {\n    http_client_with_timeout(HTTP_TIMEOUT)\n}\n\nfn http_client_with_timeout(timeout: Duration) -> Result<reqwest::blocking::Client> {\n    reqwest::blocking::Client::builder()\n        .connect_timeout(timeout.min(Duration::from_secs(10)))\n        .timeout(timeout)\n        .build()\n        .context(\"failed to build HTTP client\")\n}\n\n#[cfg(all(windows, feature = \"self-update\", not(feature = \"no-self-update\")))]\nfn replace_running_exe(args: Vec<String>) -> Result<()> {\n    if args.len() != 2 {\n        anyhow::bail!(\"usage: baml --replace <tmp> <current>\");\n    }\n    let tmp = PathBuf::from(&args[0]);\n    let current = PathBuf::from(&args[1]);\n    let mut last_error = None;\n    for _ in 0..60 {\n        std::thread::sleep(Duration::from_millis(250));\n        match fs::remove_file(&current) {\n            Ok(()) => match fs::rename(&tmp, &current) {\n                Ok(()) => return Ok(()),\n                Err(err) => last_error = Some(err),\n            },\n            Err(err) if err.kind() == std::io::ErrorKind::NotFound => {\n                match fs::rename(&tmp, &current) {\n                    Ok(()) => return Ok(()),\n                    Err(err) => last_error = Some(err),\n                }\n            }\n            Err(err) => last_error = Some(err),","sourceCodeStart":1591,"sourceCodeEnd":1627,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml/src/main.rs#L1591-L1627","documentation":"This bail occurs in `replace_running_exe`, the Windows-only helper for `baml --replace` used by the self-update feature. It expects exactly two path arguments — the downloaded temporary exe and the current running exe — and rejects any invocation with a different argument count. Since this subcommand is an internal implementation detail of the updater, seeing it means the CLI was invoked manually or the updater passed malformed arguments.","triggerScenarios":"Running `baml --replace` with zero, one, or three+ arguments instead of exactly two; calling the internal subcommand directly instead of letting the self-update flow invoke it.","commonSituations":"A user discovers the hidden `--replace` subcommand and tries it by hand; a broken or partially-downloaded updater shim invokes it with the wrong argv; a wrapper script reorders or drops arguments.","solutions":["Do not invoke `baml --replace` manually; run the normal self-update flow instead.","If calling it programmatically, pass exactly two arguments: `baml --replace <tmp-exe> <current-exe>`.","Reinstall or re-run the updater so it regenerates the correct arguments."],"exampleFix":"// before\nbaml --replace /tmp/baml-new.exe\n// after\nbaml --replace /tmp/baml-new.exe C:\\\\Program Files\\\\baml\\\\baml.exe","handlingStrategy":"validation","validationCode":"if (args.length !== 2) {\n  throw new Error('baml --replace requires exactly 2 arguments: <tmp> <current>');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never invoke the internal --replace subcommand manually; use the documented self-update command.","If scripting the updater, assert argv length is 2 before spawning the CLI."],"tags":["cli","self-update","windows","arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}