{"record":{"id":"bcfa8dc68119386a","repo":"tauri-apps/tauri","slug":"failed-to-resolve-target-directory","errorCode":null,"errorMessage":"failed to resolve target directory","messagePattern":"failed to resolve target directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tauri-cli/src/mobile/mod.rs","lineNumber":466,"sourceCode":"    asset_dir: None,\n    template_pack: None,\n  };\n\n  let app_settings = interface.app_settings();\n  let tauri_dir = tauri_dir.to_path_buf();\n  App::from_raw(tauri_dir.to_path_buf(), raw)\n    .unwrap()\n    .with_target_dir_resolver(move |target, profile| {\n      app_settings\n        .out_dir(\n          &InterfaceOptions {\n            debug: matches!(profile, Profile::Debug),\n            target: Some(target.into()),\n            ..Default::default()\n          },\n          &tauri_dir,\n        )\n        .expect(\"failed to resolve target directory\")\n    })\n}\n\n#[allow(unused_variables)]\nfn ensure_init(\n  tauri_config: &ConfigMetadata,\n  app: &App,\n  project_dir: PathBuf,\n  target: Target,\n  noninteractive: bool,\n) -> Result<()> {\n  if !project_dir.exists() {\n    crate::error::bail!(\n      \"{} project directory {} doesn't exist. Please run `tauri {} init` and try again.\",\n      target.ide_name(),\n      project_dir.display(),\n      target.command_name(),\n    )","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/tauri-apps/tauri/blob/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-cli/src/mobile/mod.rs#L448-L484","documentation":"get_app installs a target-directory resolver used by cargo-mobile2 flows; it computes the cargo out-dir for a mobile target/profile via RustAppSettings::out_dir. This expect fires when that computation errors — most plausibly an unrecognized/unsupported target triple reaching the app settings (e.g. after CLI/cargo-mobile2 version skew or a custom target), or settings derived from a malformed Cargo.toml that break out-dir resolution.","triggerScenarios":"Running `tauri android/ios dev/build` where the target identifier passed through does not map to a known Rust triple — version mismatch between tauri-cli and its cargo-mobile2 dependency, a hand-modified generated project, or invalid Cargo settings in src-tauri.","commonSituations":"Mixing CLI versions across a team (one member regenerates the android project with a different CLI); hand-edited gen/android project files; downgraded CLIs reading projects generated by newer ones.","solutions":["Align everyone on one CLI version (`npm i -D @tauri-apps/cli@latest` or `cargo install tauri-cli --locked`) and re-run.","Regenerate the mobile project: `tauri android init` / `tauri ios init` to refresh generated files and settings.","Verify src-tauri/Cargo.toml is valid: `cargo metadata --no-deps` should succeed in the workspace.","If it persists on the latest version, open an issue including the target and profile being built."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# Precheck: one CLI version for everyone and a resolvable cargo target\ncd src-tauri && cargo metadata --no-deps --format-version 1 > /dev/null && \\\n  rustup target list --installed | grep -q aarch64-linux-android || \\\n  rustup target add aarch64-linux-android","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin one @tauri-apps-cli / tauri-cli version across the team and CI; regenerate gen/android & gen/ios after upgrades.","Treat hand-edits to generated mobile projects as disposable — keep them regenerated, not maintained.","Run `tauri android init` / `tauri ios init` after CLI version changes before dev/build."],"tags":["mobile","build","target-triple","out-dir","cargo-mobile2"],"backgroundTag":"unsupported-target-triple","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}