{"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::{parse_macro_input, spanned::Spanned, ItemFn};\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/52e4b6e71d8632a7e648f866c442e287ecddee34/crates/tauri-macros/src/mobile.rs#L1-L37","documentation":"#[tauri::mobile_entry_point] generates the start_app symbol the Tauri CLI expects in mobile builds and, for Android, splices the package identifier from two compile-time env vars: TAURI_ANDROID_PACKAGE_NAME_PREFIX (reverse-domain prefix) and TAURI_ANDROID_PACKAGE_NAME_APP_NAME. get_env_var reads them during macro expansion; if either is unset the macro emits a compile error spanned over the whole function, with the hint 'do you have a build script with tauri-build?'.","triggerScenarios":"Compiling a crate that uses #[tauri::mobile_entry_point] outside the Tauri mobile flow: plain `cargo check`/`cargo build` on the host, or driving the android target with cargo directly. The vars are injected by `tauri android dev` / `tauri android build` (and mobile project generation), not by cargo itself.","commonSituations":"rust-analyzer or an editor running cargo check on a mobile lib; CI jobs that build with cargo instead of the tauri CLI; a missing or broken build.rs (no tauri_build::build()); tauri-cli and tauri crate versions out of sync.","solutions":["Build and check through the CLI: `tauri android dev` or `tauri android build` — it sets both env vars plus TAURI_ENV_*","Ensure [build-dependencies] tauri-build is present and build.rs calls tauri_build::build()","For ad-hoc cargo/rust-analyzer runs, export the vars yourself: TAURI_ANDROID_PACKAGE_NAME_PREFIX=com.example TAURI_ANDROID_PACKAGE_NAME_APP_NAME=myapp cargo check","Align tauri-cli and tauri crate versions (cargo update -p tauri; npm i -D @tauri-apps/cli@latest)"],"exampleFix":"# before:\ncargo check\n# error: `TAURI_ANDROID_PACKAGE_NAME_PREFIX` env var not set, do you have a build script with tauri-build?\n# after (option 1 - CLI):\npnpm tauri android build\n# after (option 2 - manual env for editor/CI):\nexport TAURI_ANDROID_PACKAGE_NAME_PREFIX=com.example\nexport TAURI_ANDROID_PACKAGE_NAME_APP_NAME=myapp\ncargo check","handlingStrategy":"validation","validationCode":"# gate direct cargo use of a mobile crate\n[ -n \"${TAURI_ANDROID_PACKAGE_NAME_PREFIX:-}\" ] || { echo 'TAURI_ANDROID_PACKAGE_NAME_PREFIX unset — use `tauri android build` or export it'; exit 1; }\n[ -n \"${TAURI_ANDROID_PACKAGE_NAME_APP_NAME:-}\" ] || { echo 'TAURI_ANDROID_PACKAGE_NAME_APP_NAME unset — use `tauri android build` or export it'; exit 1; }\ncargo check \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always build mobile targets through the tauri CLI, never raw cargo","Keep tauri-build in [build-dependencies] with a working build.rs","Set the two env vars in .cargo/config.toml [env] (or rust-analyzer settings) so editor cargo check passes"],"tags":["mobile","android","env-var","macros","build-script","entry-point"],"backgroundTag":"missing-env-var","analyzedSha":"52e4b6e71d8632a7e648f866c442e287ecddee34","analyzedAt":"2026-08-20T13:59:20.734Z","contentChangedAt":"2026-08-20T13:59:20.734Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}