Skip to content

fix(tauri-build): emit absolute capabilities rerun-if-changed path - #15918

Open
valorkin wants to merge 1 commit into
tauri-apps:devfrom
valorkin:fix/acl-capabilities-rerun-absolute
Open

fix(tauri-build): emit absolute capabilities rerun-if-changed path#15918
valorkin wants to merge 1 commit into
tauri-apps:devfrom
valorkin:fix/acl-capabilities-rerun-absolute

Conversation

@valorkin

Copy link
Copy Markdown

Summary

tauri-build emits a relative cargo:rerun-if-changed=capabilities in the default capabilities branch of acl::build. Cargo resolves a relative watch path against the package that owns the build script, while the glob right below it (./capabilities/**/*) is resolved against the process working directory.

Those two are the same directory for a normal app crate, so the bug is invisible there. But any caller that set_current_dirs before try_build/try_build_context — for example a separate crate that generates a context byte-identical to the app's, or a workspace layout where the build script runs from a different directory — ends up watching <caller-manifest-dir>/capabilities, which usually does not exist.

A missing watched path is dirty on every fingerprint check. The build script then re-runs on every build, which recompiles the crate and everything downstream of it. Measured in a 1.9k-unit workspace app: a zero-change cargo build took ~140s; with the watched directory present it takes ~1s.

Fix

Anchor the emitted watch path to the same base the glob already uses (std::env::current_dir()), so the watch and the parse can never disagree about which capabilities/ they mean.

Testing

  • rustfmt --check on the modified file: clean.
  • Behavior verified downstream: pointing the consumer crate at a patched tauri-build eliminates the spurious re-run (the consumer-side workaround is a committed empty capabilities/ dir with an explanatory marker, which this PR makes removable).

The relative `cargo:rerun-if-changed=capabilities` is resolved by cargo
against the package that owns the build script, while the glob in the same
branch is resolved against the process working directory. A caller that
`set_current_dir`s before `try_build[_context]` — e.g. a crate generating
a context byte-identical to the app's — ends up watching
`<caller-manifest-dir>/capabilities`, which usually does not exist. A
missing watched path is dirty on every fingerprint check, so the build
script re-runs on every build and recompiles the whole downstream chain
(measured: a zero-change build of a 1.9k-unit workspace app went from ~140s
to ~1s after making the watched dir exist).

Emit the watch path anchored to the current dir the glob already uses.
@valorkin
valorkin requested a review from a team as a code owner August 25, 2026 19:08
@github-actions

Copy link
Copy Markdown
Contributor

Package Changes Through a1a6d28

There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-build with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with minor, tauri-bundler with minor, tauri-macos-sign with minor, @tauri-apps/api with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant