diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a132206..f32278581 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +- **Fixed** Vite+ diagnostics now display individual paths and working directories without Rust debug formatting such as quoted paths or escaped Windows backslashes ([#534](https://github.com/voidzero-dev/vite-task/pull/534)). - **Fixed** Broad workspace globs no longer discover and run package scripts inside `node_modules` ([#539](https://github.com/voidzero-dev/vite-task/pull/539)). - **Added** Tasks now run with `VP_RUN=1` set, so tools can tell they are running under `vp run` instead of being invoked directly ([#570](https://github.com/voidzero-dev/vite-task/pull/570)). - **Fixed** The task cache now supports much larger automatically tracked input sets without hitting wincode's default 4 MiB sequence preallocation limit ([#554](https://github.com/voidzero-dev/vite-task/pull/554)). diff --git a/crates/fspy/src/error.rs b/crates/fspy/src/error.rs index 017d82a0e..56f983c70 100644 --- a/crates/fspy/src/error.rs +++ b/crates/fspy/src/error.rs @@ -3,7 +3,10 @@ use std::{ffi::OsString, path::PathBuf}; #[derive(thiserror::Error, Debug)] pub enum SpawnError { #[error( - "could not resolve the full path of program '{program:?}' with PATH={path:?} under cwd({cwd:?})" + "could not resolve the full path of program '{}' with PATH={} under cwd({})", + .program.display(), + .path.as_deref().unwrap_or_else(|| std::ffi::OsStr::new("")).display(), + .cwd.display() )] Which { program: OsString, diff --git a/crates/fspy_shared/src/ipc/channel/mod.rs b/crates/fspy_shared/src/ipc/channel/mod.rs index e85630379..91f6aa0aa 100644 --- a/crates/fspy_shared/src/ipc/channel/mod.rs +++ b/crates/fspy_shared/src/ipc/channel/mod.rs @@ -97,7 +97,8 @@ pub struct Sender { impl Drop for Sender { fn drop(&mut self) { if let Err(err) = self.lock_file.unlock() { - debug!("Failed to unlock the shared IPC lock {:?}: {}", self.lock_file_path, err); + let lock_file_path = self.lock_file_path.to_cow_os_str(); + debug!("Failed to unlock the shared IPC lock {}: {}", lock_file_path.display(), err); } } } @@ -147,7 +148,7 @@ unsafe impl Sync for Receiver {} impl Drop for Receiver { fn drop(&mut self) { if let Err(err) = std::fs::remove_file(&self.lock_file_path) { - debug!("Failed to remove IPC lock file {:?}: {}", self.lock_file_path, err); + debug!("Failed to remove IPC lock file {}: {}", self.lock_file_path.display(), err); } } } diff --git a/crates/vt/src/session/cache/mod.rs b/crates/vt/src/session/cache/mod.rs index cc1972bf2..06780e188 100644 --- a/crates/vt/src/session/cache/mod.rs +++ b/crates/vt/src/session/cache/mod.rs @@ -286,7 +286,7 @@ pub fn cache_schema_dir_name() -> Str { impl ExecutionCache { #[tracing::instrument(level = "debug", skip_all)] pub fn load_from_path(path: &AbsolutePath) -> anyhow::Result { - tracing::info!("Creating task cache directory at {:?}", path); + tracing::info!("Creating task cache directory at {}", path.as_path().display()); std::fs::create_dir_all(path)?; // Use file lock to prevent race conditions when multiple processes initialize the database diff --git a/crates/vt/src/session/execute/fingerprint.rs b/crates/vt/src/session/execute/fingerprint.rs index 39320c2fc..a8011ce2c 100644 --- a/crates/vt/src/session/execute/fingerprint.rs +++ b/crates/vt/src/session/execute/fingerprint.rs @@ -410,8 +410,8 @@ pub fn fingerprint_path( } if err.kind() != io::ErrorKind::NotFound { tracing::trace!( - "Uncommon error when opening {:?} for fingerprinting: {}", - std_path, + "Uncommon error when opening {} for fingerprinting: {}", + std_path.display(), err ); } diff --git a/crates/vt/src/session/mod.rs b/crates/vt/src/session/mod.rs index c622c58cb..b59cb17ea 100644 --- a/crates/vt/src/session/mod.rs +++ b/crates/vt/src/session/mod.rs @@ -616,7 +616,7 @@ impl<'a> Session<'a> { let path = self.summary_file_path(); Box::new(move |summary: &LastRunSummary| { if let Err(err) = summary.write_atomic(&path) { - tracing::warn!("Failed to write summary to {path:?}: {err}"); + tracing::warn!("Failed to write summary to {}: {err}", path.as_path().display()); } }) } diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/package.json b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/package.json new file mode 100644 index 000000000..3feb448b8 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/package.json @@ -0,0 +1,3 @@ +{ + "name": "invalid-package-json" +} diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/packages/broken/package.invalid b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/packages/broken/package.invalid new file mode 100644 index 000000000..f830e8b60 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/packages/broken/package.invalid @@ -0,0 +1,3 @@ +{ + "name": +} diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/pnpm-workspace.yaml b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/pnpm-workspace.yaml new file mode 100644 index 000000000..924b55f42 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - packages/* diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/snapshots.toml b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/snapshots.toml new file mode 100644 index 000000000..dfa058f00 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/snapshots.toml @@ -0,0 +1,18 @@ +[[e2e]] +name = "invalid_package_json_error" +comment = """ +Tests that package parse errors display paths without Rust debug formatting +""" +steps = [ + [ + "vtt", + "cp", + "packages/broken/package.invalid", + "packages/broken/package.json", + ], + [ + "vt", + "run", + "build", + ], +] diff --git a/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/snapshots/invalid_package_json_error.md b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/snapshots/invalid_package_json_error.md new file mode 100644 index 000000000..a104318d5 --- /dev/null +++ b/crates/vt_bin/tests/e2e_snapshots/fixtures/error_invalid_package_json/snapshots/invalid_package_json_error.md @@ -0,0 +1,19 @@ +# invalid_package_json_error + +Tests that package parse errors display paths without Rust debug formatting + +## `vtt cp packages/broken/package.invalid packages/broken/package.json` + +``` +``` + +## `vt run build` + +**Exit code:** 1 + +``` +error: Failed to load task graph +* Failed to load package graph +* Failed to parse JSON file at /packages/broken/package.json +* expected value at line 3 column 1 +``` diff --git a/crates/vt_graph/src/lib.rs b/crates/vt_graph/src/lib.rs index 35b04515f..e721b5f90 100644 --- a/crates/vt_graph/src/lib.rs +++ b/crates/vt_graph/src/lib.rs @@ -93,7 +93,7 @@ pub enum TaskGraphLoadError { #[error("Failed to load package graph")] PackageGraphLoadError(#[from] vt_workspace::Error), - #[error("Failed to load task config file for package at {package_path:?}")] + #[error("Failed to load task config file for package at {}", .package_path.as_path().display())] ConfigLoadError { package_path: Arc, #[source] diff --git a/crates/vt_plan/src/error.rs b/crates/vt_plan/src/error.rs index 39f4be2e9..8923c1d6b 100644 --- a/crates/vt_plan/src/error.rs +++ b/crates/vt_plan/src/error.rs @@ -47,7 +47,11 @@ impl std::fmt::Display for WhichError { #[derive(Debug, thiserror::Error)] pub enum PathFingerprintErrorKind { - #[error("Path {path:?} is outside of the workspace {workspace_path:?}")] + #[error( + "Path {} is outside of the workspace {}", + .path.as_path().display(), + .workspace_path.as_path().display() + )] PathOutsideWorkspace { path: Arc, workspace_path: Arc }, #[error("Path {path:?} contains characters that make it non-portable")] NonPortableRelativePath { @@ -119,7 +123,10 @@ pub enum Error { #[error(transparent)] TaskRecursionDetected(#[from] TaskRecursionError), - #[error("Invalid vite task command: {program} with args {args:?} under cwd {cwd:?}")] + #[error( + "Invalid vite task command: {program} with args {args:?} under cwd {}", + .cwd.as_path().display() + )] ParsePlanRequest { program: Str, args: Arc<[Str]>, diff --git a/crates/vt_server/src/lib.rs b/crates/vt_server/src/lib.rs index d5401f7c9..6869f58a5 100644 --- a/crates/vt_server/src/lib.rs +++ b/crates/vt_server/src/lib.rs @@ -45,7 +45,7 @@ pub enum Error { #[error("invalid message from the task")] InvalidRequest(#[source] wincode::ReadError), - #[error("non-absolute path from the task: {path:?}")] + #[error("non-absolute path from the task: {}", .path.display())] NonAbsolutePath { path: OsString }, #[error("invalid glob pattern from the task: {:?}", .0.pattern)] diff --git a/crates/vt_server/tests/integration.rs b/crates/vt_server/tests/integration.rs index fd9daef10..edc5374bd 100644 --- a/crates/vt_server/tests/integration.rs +++ b/crates/vt_server/tests/integration.rs @@ -234,6 +234,8 @@ fn server_returns_error_on_non_absolute_path() { }) .expect_err("driver should surface the protocol error"); + assert_eq!(err.to_string(), "non-absolute path from the task: relative/path"); + match err { Error::NonAbsolutePath { path } => { assert_eq!(path, OsStr::new("relative/path")); diff --git a/crates/vt_workspace/src/error.rs b/crates/vt_workspace/src/error.rs index 36c1a8a58..538d77c14 100644 --- a/crates/vt_workspace/src/error.rs +++ b/crates/vt_workspace/src/error.rs @@ -16,10 +16,14 @@ pub enum Error { #[error("Duplicate package name `{name}` found at `{path1}` and `{path2}`")] DuplicatedPackageName { name: Str, path1: RelativePathBuf, path2: RelativePathBuf }, - #[error("Package not found in workspace: `{0:?}`")] + #[error("Package not found in workspace: `{}`", .0.as_path().display())] PackageJsonNotFound(AbsolutePathBuf), - #[error("Package at `{package_path:?}` is outside workspace root `{workspace_root:?}`")] + #[error( + "Package at `{}` is outside workspace root `{}`", + .package_path.as_path().display(), + .workspace_root.as_path().display() + )] PackageOutsideWorkspace { package_path: Arc, workspace_root: Arc }, #[error( @@ -35,14 +39,14 @@ pub enum Error { #[error(transparent)] Io(#[from] io::Error), - #[error("Failed to parse JSON file at {file_path:?}")] + #[error("Failed to parse JSON file at {}", .file_path.as_path().display())] SerdeJson { file_path: Arc, #[source] serde_json_error: serde_json::Error, }, - #[error("Failed to parse YAML file at {file_path:?}")] + #[error("Failed to parse YAML file at {}", .file_path.as_path().display())] SerdeYaml { file_path: Arc, #[source]