Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-capabilities-rerun-absolute-path.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-build': 'patch:bug'
---

Emit an absolute path for the capabilities directory `cargo:rerun-if-changed`. Cargo resolves a relative watch path against the package owning the build script, while the capabilities glob is resolved against the process working directory, so callers that change the current directory before `try_build`/`try_build_context` ended up watching a non-existent directory — which is always dirty and re-ran the build script (and recompiled everything downstream) on every build.
14 changes: 13 additions & 1 deletion crates/tauri-build/src/acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,19 @@ pub fn build(out_dir: &Path, target: Target, attributes: &Attributes) -> super::
let capabilities = if let Some(pattern) = attributes.capabilities_path_pattern {
tauri_utils::acl::build::parse_capabilities(pattern)?
} else {
println!("cargo:rerun-if-changed=capabilities");
// Emit an absolute watch path: cargo resolves a relative
// `rerun-if-changed` against the package that owns the build script, while
// the glob below is resolved against the process working directory.
// Callers that `set_current_dir` before `try_build[_context]` (for example
// a crate generating a context byte-identical to the app's) would
// otherwise watch a `<caller-manifest-dir>/capabilities` that usually does
// not exist — and a missing watched path is dirty on every fingerprint
// check, re-running the build script and recompiling the whole downstream
// chain on every build.
let capabilities_dir = std::env::current_dir()
.context("resolve current dir for capabilities watch path")?
.join("capabilities");
println!("cargo:rerun-if-changed={}", capabilities_dir.display());
tauri_utils::acl::build::parse_capabilities("./capabilities/**/*")?
};
validate_capabilities(&acl_manifests, &capabilities)?;
Expand Down