diff --git a/crates/vite_task/src/session/cache/mod.rs b/crates/vite_task/src/session/cache/mod.rs index 885dc97d6..690d50d43 100644 --- a/crates/vite_task/src/session/cache/mod.rs +++ b/crates/vite_task/src/session/cache/mod.rs @@ -176,7 +176,7 @@ pub fn split_path(path: &str) -> (Option<&str>, &str) { impl ExecutionCache { #[tracing::instrument(level = "debug", skip_all)] - pub fn load_from_path(path: &AbsolutePath) -> anyhow::Result { + pub fn load_from_path(path: &AbsolutePath, program_name: &str) -> anyhow::Result { tracing::info!("Creating task cache directory at {:?}", path); std::fs::create_dir_all(path)?; @@ -211,7 +211,11 @@ impl ExecutionCache { } 11 => break, // current version 12.. => { - return Err(anyhow::anyhow!("Unrecognized database version: {user_version}")); + return Err(anyhow::anyhow!( + "Unrecognized database version: {user_version}. \ + The cache may have been created by a newer version of Vite Task. \ + Run `{program_name} cache clean` to remove it." + )); } } } diff --git a/crates/vite_task/src/session/mod.rs b/crates/vite_task/src/session/mod.rs index a6968c90e..eb9ca6411 100644 --- a/crates/vite_task/src/session/mod.rs +++ b/crates/vite_task/src/session/mod.rs @@ -554,7 +554,9 @@ impl<'a> Session<'a> { /// /// Returns an error if the cache database cannot be loaded or created. pub fn cache(&self) -> anyhow::Result<&ExecutionCache> { - self.cache.get_or_try_init(|| ExecutionCache::load_from_path(&self.cache_path)) + self.cache.get_or_try_init(|| { + ExecutionCache::load_from_path(&self.cache_path, &self.program_name) + }) } pub fn workspace_path(&self) -> Arc {