tauri-apps/tauri · error · tauri_cli::error::Error
{} project directory {} doesn't exist. Please run `tauri {}
Error message
{} project directory {} doesn't exist. Please run `tauri {} init` and try again. What it means
`ensure_init` runs before every `tauri android/ios dev|build` and verifies that the generated mobile project directory exists (e.g. `src-tauri/gen/android` or `src-tauri/gen/ios`). If it is missing, the platform tooling cannot proceed and you are told to run the matching init command.
Source
Thrown at crates/tauri-cli/src/mobile/mod.rs:479
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(),
)
}
let mut project_outdated_reasons = Vec::new();
match target {
Target::Android => {
let java_folder = project_dir
.join("app/src/main/java")
.join(tauri_config.identifier.replace('.', "/").replace('-', "_"));
if java_folder.exists() {
#[cfg(unix)]
ensure_gradlew(&project_dir)?;
} else {View on GitHub (pinned to 52e4b6e71d)
Solutions
- Run `tauri android init` or `tauri ios init` from the project root (where the tauri config is).
- If gen/ was deleted, re-run init — it regenerates the project.
- Commit the generated project (Tauri recommends committing gen/ios; for android at least ensure CI runs init).
- Verify the directory exists afterwards: `ls src-tauri/gen/android`.
Example fix
# before tauri android dev # error: Android Studio project directory src-tauri/gen/android doesn't exist # after tauri android init tauri android dev
Defensive patterns
Strategy: validation
Validate before calling
# Before dev/build, ensure the generated project exists
for plat in android ios; do
test -d "src-tauri/gen/$plat" || { echo "missing gen/$plat - run: tauri $plat init"; }
done Prevention
- Run `tauri ios init`/`tauri android init` as the first step after cloning on a new machine.
- Decide as a team whether gen/ is committed, and make CI run init when it is not.
- Always run tauri CLI commands from the directory containing the tauri config.
When it happens
Trigger: Executing `tauri android dev`/`tauri ios build` (etc.) in a repo where `tauri android init` / `tauri ios init` was never run, or where `src-tauri/gen/` was deleted, never committed by a .gitignore (gen/android is typically ignored), or the command is run from the wrong working directory so the tauri config is not found.
Common situations: Fresh clone of a project whose `gen/` folder is gitignored; a teammate assuming gen output is committed; running the CLI outside the project root; CI jobs that skip init.
Related errors
- No external IP detected.
- failed to read missing addr file {}: {e}
- iOS platform not installed
- {} project directory is outdated because {reason}. Please de
- Android folder already exists
AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20).
Data as JSON: /api/errors/9cce383278e6de58.
Report an issue: GitHub.