tauri-apps/tauri · error
failed to resolve target directory
Error message
failed to resolve target directory
What it means
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.
Source
Thrown at crates/tauri-cli/src/mobile/mod.rs:466
asset_dir: None,
template_pack: None,
};
let app_settings = interface.app_settings();
let tauri_dir = tauri_dir.to_path_buf();
App::from_raw(tauri_dir.to_path_buf(), raw)
.unwrap()
.with_target_dir_resolver(move |target, profile| {
app_settings
.out_dir(
&InterfaceOptions {
debug: matches!(profile, Profile::Debug),
target: Some(target.into()),
..Default::default()
},
&tauri_dir,
)
.expect("failed to resolve target directory")
})
}
#[allow(unused_variables)]
fn ensure_init(
tauri_config: &ConfigMetadata,
app: &App,
project_dir: PathBuf,
target: Target,
noninteractive: bool,
) -> Result<()> {
if !project_dir.exists() {
crate::error::bail!(
"{} project directory {} doesn't exist. Please run `tauri {} init` and try again.",
target.ide_name(),
project_dir.display(),
target.command_name(),
)View on GitHub (pinned to 52e4b6e71d)
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.
Defensive patterns
Strategy: validation
Validate before calling
# Precheck: one CLI version for everyone and a resolvable cargo target cd src-tauri && cargo metadata --no-deps --format-version 1 > /dev/null && \ rustup target list --installed | grep -q aarch64-linux-android || \ rustup target add aarch64-linux-android
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unexpected target triple {}
- cannot use both `resources` and `resources_map`
- Language {} not found. It must be one of {}
- No external IP detected.
- failed to read missing addr file {}: {e}
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/bcfa8dc68119386a.
Report an issue: GitHub.