{"record":{"id":"2415604f89158008","repo":"gitbutlerapp/gitbutler","slug":"run-cargo-target-dir-pwd-target-tauri-cargo-buil","errorCode":null,"errorMessage":"Run `CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but` to build the `but` binary","messagePattern":"Run `CARGO_TARGET_DIR=\\$PWD/target/tauri cargo build -p but` to build the `but` binary","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-action/src/cli.rs","lineNumber":116,"sourceCode":"        }\n    } else {\n        Err(anyhow!(\n            \"Would probably need to run \\\"ln -sf '{}' '{UNIX_LINK_PATH}'\\\"{privilege}\",\n            cli_path.display(),\n            privilege = if can_elevate_privileges {\n                \" with root permissions\"\n            } else {\n                \"\"\n            }\n        ))\n    }\n}\n\nfn ensure_cli_path_exists_prior_to_link(cli_path: &std::path::Path) -> anyhow::Result<()> {\n    if cli_path.exists() {\n        return Ok(());\n    }\n    bail!(\"Run `CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but` to build the `but` binary\")\n}\n\n/// On Windows, we'll provide helpful instructions rather than attempt automatic installation\n/// since:\n/// 1. Creating symlinks requires developer mode or admin privileges\n/// 2. There's no standard user-writable directory that's always in PATH\n/// 3. Users typically add directories to PATH manually on Windows\n///\n/// Note that this isn't usually called on Windows.\n#[cfg(windows)]\nfn install_cli_windows(cli_path: std::path::PathBuf) -> anyhow::Result<()> {\n    let but_filename = cli_path\n        .file_name()\n        .context(\"BUG: encountered but CLI path without /\")?;\n\n    bail!(\n        \"Automatic CLI installation is not supported on Windows.\\n\\\n        \\n\\","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-action/src/cli.rs#L98-L134","documentation":"Before creating or repairing the /usr/local/bin/but symlink, the installer verifies the built CLI binary exists at the expected Tauri target-dir path. If the `but` crate was never compiled into $PWD/target/tauri, it bails with the exact build command to run (crates/but-action/src/cli.rs:116).","triggerScenarios":"Invoking the desktop app's 'install CLI' action (do_install_cli / ensure_cli_path_exists_prior_to_link) on a dev checkout where `cargo build -p but` was never run with CARGO_TARGET_DIR=$PWD/target/tauri, or where the target dir was cleaned/moved.","commonSituations":"Fresh clone after a clean/build step that skips the Rust CLI; running the app from a build that did not bundle the CLI; CI artifacts assembled without the but binary; cargo clean before installing.","solutions":["From the repository root run `CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but`, then retry the install","Verify the binary exists at the path reported by get_cli_path() before retrying","If the target dir was moved, rebuild so the binary lands at the expected location"],"exampleFix":"# before: install CLI from the app -> bail: 'Run `CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but`...'\n# after:\n$ cd <repo-root>\n$ CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but\n$ # retry the install action; symlink is now created","handlingStrategy":"validation","validationCode":"// Verify the built binary exists before install\nlet cli_path = get_cli_path()?;\nif !cli_path.exists() {\n    // run: CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but\n    anyhow::bail!(\"build the but binary first: CARGO_TARGET_DIR=$PWD/target/tauri cargo build -p but\");\n}\ndo_install_cli(mode)?;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make `cargo build -p but` (with the Tauri CARGO_TARGET_DIR) part of the dev setup script","Never run cargo clean between building the CLI and installing the link","In CI, assert the CLI artifact exists before the install step"],"tags":["rust","cli","build","dev-setup","but-action"],"backgroundTag":"binary-not-built","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}