`project.dependency_metadata` calls `system` APIs
Author: MichaReiserCreated Sep 27, 2026Updated Sep 30, 2026
Labelsbuguv
Summary
Stale invalid environment, missing selected environment, and environment mismatch diagnostics.
system APIs bypass Salsa's cache invalidation, which can result in stale query results.
let environment = workspace
.environment()
.ok_or(DependencyMetadataError::MissingEnvironment)?;
let environment = db
.system()
.canonicalize_path(environment)
.map_err(|error| DependencyMetadataError::InvalidEnvironment {
path: environment.to_path_buf(),
message: error.to_string().into(),
})?;
let selected_environment = metadata
.to_merged_options()
.python_environment(db.system())
.map_err(|error| {
DependencyMetadataError::EnvironmentResolution(error.to_string().into())
})?
.ok_or(DependencyMetadataError::MissingSelectedEnvironment)?;
// An explicit Python environment can override uv's selection. Its installed modules may
// belong to different distributions, so uv's ownership map cannot describe those imports.
if selected_environment.sys_prefix().as_std_path() != environment.as_std_path() {
return Err(DependencyMetadataError::EnvironmentMismatch {
selected: selected_environment.sys_prefix().to_path_buf(),
selected_origin: selected_environment.origin().to_string().into(),
uv: environment,
});
}depedency_metadata calls:
canonicalize_path.python_environment
With https://github.com/astral-sh/ruff/pull/28650, we now store the virtual environment path on the resolved ProgramSettings. We could consider storing the full PythonEnvironment, if necessary, or a selected set of resolved paths that dependency_metadata needs, but we should not use any system APIs (I'm surprised our clippy rule didn't flag this, but that's another issue). An alternative is to use the Salsa tracked directory API.
Version
No response
Source: astral-sh/ty