fix: Search gitignored directories for config files - #12791
Conversation
|
hmm, this wasn't really a "bug". It was added intentionally because for many users the cli took ages to find the config. As a compromise we added a manual check for Also, this change is a bit extra extreme as it even disables tauri's own gitignore file... i don't mind somehow improving the lookup but i personally would not merge a PR that heavily degrades dx for most of our users for the 10 people that gitignored their whole system. |
|
Fixing the manual check would work for me as well. I'm left with two things I don't understand:
|
performance reasons
first of all, that's what i meant with tauri's own gitignore file, secondly it's a bit hard to predict what kind of folders have to be gitignored (with the tauri dir potentially being in a dir with an unfortunate name). i'm not totally against this approach though.
If |
Of course. I just measured the runtime of the call to |
|
If you want to test this yourself, you can Diff, hidden for readability
diff --git a/crates/tauri-cli/src/helpers/app_paths.rs b/crates/tauri-cli/src/helpers/app_paths.rs
index b20b991ef..3d209f9dd 100644
--- a/crates/tauri-cli/src/helpers/app_paths.rs
+++ b/crates/tauri-cli/src/helpers/app_paths.rs
@@ -8,6 +8,7 @@ use std::{
ffi::OsStr,
path::{Path, PathBuf},
sync::OnceLock,
+ time::Instant,
};
use ignore::WalkBuilder;
@@ -101,7 +102,8 @@ pub fn resolve_tauri_dir() -> Option<PathBuf> {
return Some(src_dir);
}
- lookup(&src_dir, |path| {
+ let earlier = Instant::now();
+ let result = lookup(&src_dir, |path| {
folder_has_configuration_file(Target::Linux, path) || is_configuration_file(Target::Linux, path)
})
.map(|p| {
@@ -110,7 +112,13 @@ pub fn resolve_tauri_dir() -> Option<PathBuf> {
} else {
p.parent().unwrap().to_path_buf()
}
- })
+ });
+
+ let duration = Instant::now().duration_since(earlier);
+
+ dbg!(duration);
+
+ result
}
pub fn resolve() { |
Was there really a concrete issue with performance before this was added? |
|
yes, the 10 seconds i mentioned weren't an exaggeration, a few people actually faced delays that long (including me when i tested their projects). |
|
I see, thanks for the insight. How do you suggest we move forward now? Even assuming that searching for the config file in the wrong places is causing performance issues, using the .gitignore file for this feels like a band-aid fix. Maybe we can build something less brittle by manually ignoring the usual suspects ( |
That's what i meant with "tauri's own gitignore file" in my first message. Judging by the reports we've got so far from those that had issues with the current lookup, simply setting This would the route i'd prefer. First we disable the parent dir gitignore files and then wait a while to see if there's a need to go further. (again, nobody that complained about this had the config ignored in their project directly iirc) |
|
Thank you! |
Fixes #3527
This PR changes the
lookupfunction to search gitignored directories as well.lookupis used to find the tauri config and package.json files.#3527 was closed without being fixed: Tauri v2 currently can't find its config files if they are gitignored, as is often the case for people who track their dotfiles with a git repo in their home directory.