tauri-apps/tauri · error

missing `cargo:dev` instruction, please update tauri to late

Error message

missing `cargo:dev` instruction, please update tauri to latest

What it means

tauri_build::is_dev() reads the DEP_TAURI_DEV environment variable, which Cargo only sets when the linked tauri runtime crate's build script prints cargo:dev=<bool> (crates/tauri/build.rs:261) through its links declaration. The expect fires when that variable is absent, i.e. the tauri crate actually linked is older than the tauri-build crate driving the build. It is a version-lock assertion between the two crates, not a general environment problem.

Source

Thrown at crates/tauri-build/src/lib.rs:468

  ///
  /// See [`AppManifest`] for more information.
  pub fn app_manifest(mut self, manifest: AppManifest) -> Self {
    self.app_manifest = manifest;
    self
  }

  #[cfg(feature = "codegen")]
  #[cfg_attr(docsrs, doc(cfg(feature = "codegen")))]
  #[must_use]
  pub fn codegen(mut self, codegen: codegen::context::CodegenContext) -> Self {
    self.codegen.replace(codegen);
    self
  }
}

pub fn is_dev() -> bool {
  env::var_os("DEP_TAURI_DEV")
    .expect("missing `cargo:dev` instruction, please update tauri to latest")
    == "true"
}

/// Run all build time helpers for your Tauri Application.
///
/// To provide extra configuration, such as [`AppManifest::commands`]
/// for fine-grained control over command permissions, see [`try_build`].
/// See [`Attributes`] for the complete list of configuration options.
///
/// # Platforms
///
/// [`build()`] should be called inside of `build.rs` regardless of the platform, so **DO NOT** use a [conditional compilation]
/// check that prevents it from running on any of your targets.
///
/// Platform specific code is handled by the helpers automatically.
///
/// A build script is required in order to activate some cargo environmental variables that are
/// used when generating code and embedding assets.

View on GitHub (pinned to 52e4b6e71d)

Solutions

  1. Update both crates in lockstep: set tauri and tauri-build to the same latest 2.x line in Cargo.toml, then run cargo update -p tauri -p tauri-build
  2. Run cargo tree -i tauri (and -i tauri-build) to find which member or dependency pins the mismatched version, and align it
  3. If the lockfile is stale, delete the relevant lock entries or run a plain cargo update after fixing Cargo.toml
  4. For a forked tauri, either cherry-pick the build-script change that emits cargo:dev or match tauri-build to the fork's era

Example fix

// Cargo.toml (src-tauri) — before
[build-dependencies]
tauri-build = "2"
[dependencies]
tauri = "1.6"

// after — both on the same line
[build-dependencies]
tauri-build = "2"
[dependencies]
tauri = "2"
Defensive patterns

Strategy: validation

Validate before calling

# CI preflight: tauri and tauri-build must share the same version line
v1=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="tauri") | .version' | head -1)
v2=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name=="tauri-build") | .version' | head -1)
[ "${v1%%.*}" = "${v2%%.*}" ] || { echo "tauri $v1 vs tauri-build $v2 mismatch"; exit 1; }

Try / catch

// build.rs — catch the panic and print an actionable message
let result = std::panic::catch_unwind(tauri_build::build);
if result.is_err() {
  eprintln!("tauri-build failed; most likely tauri and tauri-build versions are out of sync — align both to the same release");
  std::process::exit(1);
}

Prevention

When it happens

Trigger: Calling tauri_build::build() (which calls is_dev()) in build.rs while the project pairs a newer tauri-build with an older tauri runtime crate that never emits cargo:dev — typically after upgrading only one crate, or when Cargo.lock resolves a stale tauri.

Common situations: Upgrading tauri-build without upgrading tauri (or vice versa) during a v1-to-v2 migration; stale lockfile after editing versions; workspace members pinning different tauri/tauri-build releases; using a fork of tauri predating the cargo:dev instruction.

Related errors


AI-assisted analysis of tauri-apps/tauri@52e4b6e71d (2026-08-20). Data as JSON: /api/errors/46b6a1fd5d213935. Report an issue: GitHub.