Skip to content

fix(cli): keep watching folders matched by .taurignore, filter entries and events - #16398

Merged
Legend-Master merged 3 commits into
tauri-apps:devfrom
ashokram-si:fix/taurignore-root-9163
Nov 12, 2026
Merged

Legend-Master merged 3 commits into
tauri-apps:devfrom
ashokram-si:fix/taurignore-root-9163

Conversation

@ashokram-si

@ashokram-si ashokram-si commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #9163.

The watcher always walks the watch folders instead of skipping them when the root matches an ignore pattern like /*. A small helper, watch_targets, relies on the existing lookup walker to pick up only the entries that are not ignored, and change events are still filtered by the event loop. Includes unit tests and an end-to-end check with the .taurignore from #9163.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through 8048ddb

There are 9 changes which include @tauri-apps/api with patch, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-codegen with patch, tauri-runtime with patch, tauri with patch, tauri-runtime-wry with patch, tauri-utils with patch

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.12.4 2.12.5
tauri-utils 2.10.2 2.10.3
tauri-bundler 2.10.4 2.10.5
tauri-runtime 2.12.2 2.12.3
tauri-runtime-wry 2.12.3 2.12.4
tauri-codegen 2.7.4 2.7.5
tauri-macros 2.7.4 2.7.5
tauri-plugin 2.7.2 2.7.3
tauri-build 2.7.4 2.7.5
tauri 2.12.5 2.12.6
@tauri-apps/cli 2.12.4 2.12.5
tauri-cli 2.12.4 2.12.5

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


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

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative matches are a bit tricky to support actually, I don't think always ignoring /* as a special case makes sense here. I wonder if we should just always watch the folders but ignore the events instead? cc @FabianLars

@ashokram-si

Copy link
Copy Markdown
Contributor Author

Hey @Legend-Master, thanks for pointing that out. You are completely right about not handling /* as a special case, and your suggestion makes total sense.

I pushed a new commit (9ed83d4) that removes that root exception entirely. Now the watcher always walks the watch folders instead of skipping them when the root matches:

-    for path in watch_folders {
-      if !ignore_matcher.is_ignore(&path, true) {
-        log::info!("Watching {} for changes...", display_path(&path));
-        lookup(&path, |file_type, p| { /* watch p */ });
-      }
+    for path in &watch_folders {
+      log::info!("Watching {} for changes...", display_path(path));
+    }
+    for (path, mode) in watch_targets(&watch_folders) {
+      log::debug!("Watching {} for changes...", display_path(&path));
+      let _ = watcher.watch(&path, mode);
     }

We use a small helper called watch_targets that relies on the existing lookup walker to pick up only the entries that are actually not ignored:

fn watch_targets(watch_folders: &[PathBuf]) -> Vec<(PathBuf, RecursiveMode)> {
  let mut targets = Vec::new();
  for path in watch_folders {
    lookup(path, |file_type, p| {
      if p != *path {
        let mode = if file_type.is_dir() {
          RecursiveMode::Recursive
        } else {
          RecursiveMode::NonRecursive
        };
        targets.push((p, mode));
      }
    });
  }
  targets
}

Change events are still filtered properly by the event loop. I also updated the tests to cover this properly, using the .taurignore from #9163:

/*
!/*.toml
!/*.rs
!/src
  • watch_targets_watch_a_folder_whose_taurignore_matches_it: only Cargo.toml and src are watched (the old folder check watched nothing).
  • ignore_matcher_filters_events_under_a_root_wide_pattern: src/main.rs and Cargo.toml pass, README.md is ignored.

Running tauri dev with that file: editing README.md triggers no rebuild, editing src/main.rs triggers one.

I cleaned up the PR title and description to match the new approach. Let me know what you think!

@ashokram-si ashokram-si changed the title fix(cli): don't ignore own directory in .taurignore fix(cli): keep watching folders matched by .taurignore, filter entries and events Oct 27, 2026
Closes tauri-apps#9163.

Prevents `IgnoreMatcher` from treating `.taurignore`'s root directory as ignored when using `/*`, matching standard `.gitignore` behavior. Includes unit tests.
…s and events

Walk every watch folder even when an ignore pattern such as `/*` matches the folder itself, and apply the ignore rules to its entries and to change events. This replaces the root special case in IgnoreMatcher::is_ignore.
@ashokram-si
ashokram-si force-pushed the fix/taurignore-root-9163 branch from 429cb6c to db4552f Compare October 27, 2026 09:04

@Legend-Master Legend-Master left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks correct to me, thanks!

cc @FabianLars I'm not the most familiar with how file watchers are done, so want to ask you for a review as well

from my past experiences with https://github.com/parcel-bundler/watcher used in vscode, they seemed to just watch the whole folder and then match ignore patterns before it reaches the application code, this change basically matches that

@FabianLars FabianLars left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not tested but looks reasonable

@Legend-Master
Legend-Master merged commit 7facf4f into tauri-apps:dev Nov 12, 2026
17 checks passed
@ashokram-si
ashokram-si deleted the fix/taurignore-root-9163 branch November 13, 2026 12:03
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.

[bug] taurignore excluding all file except for few of crate excludes entire crate not working

3 participants