{"record":{"id":"a7940fb74a2da872","repo":"tauri-apps/tauri","slug":"name-env-var-not-set-do-you-have-a-build-scri","errorCode":null,"errorMessage":"`{name}` env var not set, do you have a build script with tauri-build?","messagePattern":"`(.+?)` env var not set, do you have a build script with tauri-build\\?","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/tauri-macros/src/mobile.rs","lineNumber":19,"sourceCode":"// Copyright 2019-2024 Tauri Programme within The Commons Conservancy\n// SPDX-License-Identifier: Apache-2.0\n// SPDX-License-Identifier: MIT\n\nuse proc_macro::TokenStream;\nuse proc_macro2::TokenStream as TokenStream2;\nuse quote::{format_ident, quote};\nuse std::env::var;\nuse syn::{ItemFn, parse_macro_input, spanned::Spanned};\n\nfn get_env_var(name: &str, error: &mut Option<TokenStream2>, function: &ItemFn) -> TokenStream2 {\n  match var(name) {\n    Ok(value) => {\n      let ident = format_ident!(\"{value}\");\n      quote!(#ident)\n    }\n    Err(_) => {\n      error.replace(\n        syn::Error::new(\n          function.span(),\n          format!(\"`{name}` env var not set, do you have a build script with tauri-build?\",),\n        )\n        .into_compile_error(),\n      );\n      quote!()\n    }\n  }\n}\n\npub fn entry_point(_attributes: TokenStream, item: TokenStream) -> TokenStream {\n  let function = parse_macro_input!(item as ItemFn);\n  let function_name = function.sig.ident.clone();\n\n  let mut error = None;\n  let domain = get_env_var(\"TAURI_ANDROID_PACKAGE_NAME_PREFIX\", &mut error, &function);\n  let app_name = get_env_var(\"TAURI_ANDROID_PACKAGE_NAME_APP_NAME\", &mut error, &function);\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/tauri-apps/tauri/blob/460ec35447493200d64290dd7f015d5a91d0fd58/crates/tauri-macros/src/mobile.rs#L1-L37","documentation":"The `#[tauri::mobile_entry_point]` macro builds the Android entry-point symbol from environment variables set by tauri-build (TAURI_ANDROID_PACKAGE_NAME_PREFIX and TAURI_ANDROID_PACKAGE_NAME_APP_NAME). If either variable is missing, the macro emits this compile error pointing at the annotated function.","triggerScenarios":"Using `#[tauri::mobile_entry_point]` in a crate whose build script does not run tauri_build::build(), or building outside the normal Tauri CLI flow so those env vars are never exported.","commonSituations":"Adding a new binary/lib crate to an Android project without a build.rs; running `cargo build` directly instead of via `tauri android build`; stale build cache after adding mobile support.","solutions":["Add a build.rs that calls tauri_build::build() to the crate using the macro","Build through the Tauri CLI (`tauri android build` / `tauri android dev`) rather than raw cargo","Verify tauri-build is a build-dependency in Cargo.toml and the build script is not ignored"],"exampleFix":"// before (no build script)\n// Cargo.toml: only [dependencies]\n// after\n// build.rs\nfn main() { tauri_build::build(); }\n// Cargo.toml\n[build-dependencies]\ntauri-build = { version = \"2\", features = [] }","handlingStrategy":"validation","validationCode":"// build.rs sanity check before the macro runs\nfn main() {\n  tauri_build::build();\n  println!(\"cargo:rustc-env=CHECK=ok\");\n}\n// shell check:\n// [ -n \"$TAURI_ANDROID_PACKAGE_NAME_PREFIX\" ] || echo \"run via tauri android build\"","typeGuard":null,"tryCatchPattern":"// The macro emits a compile_error!, so the fix is in the build setup, not catch code.\n// Ensure build.rs exists and CI invokes `tauri android build`, not bare `cargo build --target=aarch64-linux-android`.","preventionTips":["Always have build.rs calling tauri_build::build() in crates using mobile entry points","Build Android targets only through the Tauri CLI","Add a CI assertion that builds via tauri CLI so env vars are set"],"tags":["compile-time","macro","env-var","android","build-script"],"backgroundTag":"missing-env-var","analyzedSha":"460ec35447493200d64290dd7f015d5a91d0fd58","analyzedAt":"2026-09-18T23:55:51.277Z","contentChangedAt":"2026-09-18T23:55:51.277Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}