Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions crates/tauri-cli/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,7 @@ pub fn setup(
.canonicalize()
.fs_context("failed to canonicalize path", path.to_path_buf())?;

let ip = options
.host
.unwrap_or_else(|| Ipv4Addr::new(127, 0, 0, 1).into());
let ip = options.host.unwrap_or_else(|| Ipv4Addr::LOCALHOST.into());

let server_url = builtin_dev_server::start(path, ip, options.port)
.context("failed to start builtin dev server")?;
Expand Down
74 changes: 39 additions & 35 deletions crates/tauri-cli/src/interface/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use tauri_utils::config::{parse::is_configuration_file, DeepLinkProtocol, Runner

use super::{AppSettings, DevProcess, ExitReason};
use crate::{
error::{Context, Error, ErrorExt},
error::{bail, Context, Error, ErrorExt},
helpers::{
app_paths::Dirs,
config::{nsis_settings, reload_config, wix_settings, BundleResources, Config, ConfigMetadata},
Expand Down Expand Up @@ -144,9 +144,10 @@ impl Rust {
}
})
.unwrap();
let manifest_path = tauri_dir.join("Cargo.toml");
watcher
.watch(tauri_dir.join("Cargo.toml"), RecursiveMode::NonRecursive)
.with_context(|| format!("failed to watch {}", tauri_dir.join("Cargo.toml").display()))?;
.watch(&manifest_path, RecursiveMode::NonRecursive)
.with_context(|| format!("failed to watch {}", manifest_path.display()))?;
let (manifest, modified) = rewrite_manifest(config, tauri_dir)?;
if modified {
// Wait for the modified event so we don't trigger a re-build later on
Expand Down Expand Up @@ -553,43 +554,46 @@ impl Rust {
}
}

loop {
if let Ok(events) = rx.recv() {
for event in events {
if event.kind.is_access() {
continue;
}
while let Ok(events) = rx.recv() {
for event in events {
if event.kind.is_access() {
continue;
}

let Some(event_path) = event.paths.first() else {
continue;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks a bit odd only using the first path? Could maybe use a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure why, I simply did a Convert to guarded return refactor using rust analyzer here

Copy link
Contributor

Choose a reason for hiding this comment

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

Clearly a behavior-preserving refactor, just a drive-by remark.

Copy link
Contributor Author

@Legend-Master Legend-Master Jan 30, 2026

Choose a reason for hiding this comment

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

Seems like it's from #12164 when we switched to debouncer full which uses it for rename events, I'll see if we want to handle it here

Copy link
Member

Choose a reason for hiding this comment

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

I'll see if we want to handle it here

i don't see why we would want to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For also accounting the renamed to file?

Copy link
Member

Choose a reason for hiding this comment

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

haha yes obviously. I can't remember what I was getting at anymore, just that I think there's little benefit in behavior compared to the lines of code added - since it's just 5 or so you can ignore me and go on with your day x)


if ignore_matcher.is_ignore(event_path, event_path.is_dir()) {
continue;
}

if let Some(event_path) = event.paths.first() {
if !ignore_matcher.is_ignore(event_path, event_path.is_dir()) {
if is_configuration_file(self.app_settings.target_platform, event_path)
&& reload_config(config, merge_configs, dirs.tauri).is_ok()
{
let (manifest, modified) = rewrite_manifest(config, dirs.tauri)?;
if modified {
*self.app_settings.manifest.lock().unwrap() = manifest;
// no need to run the watcher logic, the manifest was modified
// and it will trigger the watcher again
continue;
}
}

log::info!(
"File {} changed. Rebuilding application...",
display_path(event_path.strip_prefix(dirs.frontend).unwrap_or(event_path))
);

child.kill().context("failed to kill app process")?;

// wait for the process to exit
// note that on mobile, kill() already waits for the process to exit (duct implementation)
let _ = child.wait();
child = run(self, config)?;
}
if is_configuration_file(self.app_settings.target_platform, event_path)
&& reload_config(config, merge_configs, dirs.tauri).is_ok()
{
let (manifest, modified) = rewrite_manifest(config, dirs.tauri)?;
if modified {
*self.app_settings.manifest.lock().unwrap() = manifest;
// no need to run the watcher logic, the manifest was modified
// and it will trigger the watcher again
continue;
}
}

log::info!(
"File {} changed. Rebuilding application...",
display_path(event_path.strip_prefix(dirs.frontend).unwrap_or(event_path))
);

child.kill().context("failed to kill app process")?;

// wait for the process to exit
// note that on mobile, kill() already waits for the process to exit (duct implementation)
let _ = child.wait();
child = run(self, config)?;
}
}
bail!("File watcher exited unexpectedly")
}
}

Expand Down
Loading