mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Avoid creating cache directories in tool directory (#4868)
Closes https://github.com/astral-sh/uv/issues/4867.
This commit is contained in:
parent
a302d704c5
commit
389582a37e
2 changed files with 16 additions and 10 deletions
|
@ -11,7 +11,11 @@ use crate::commands::ExitStatus;
|
|||
use crate::printer::Printer;
|
||||
|
||||
/// List installed tools.
|
||||
pub(crate) async fn list(preview: PreviewMode, printer: Printer) -> Result<ExitStatus> {
|
||||
pub(crate) async fn list(
|
||||
preview: PreviewMode,
|
||||
cache: &Cache,
|
||||
printer: Printer,
|
||||
) -> Result<ExitStatus> {
|
||||
if preview.is_disabled() {
|
||||
warn_user_once!("`uv tool list` is experimental and may change without warning.");
|
||||
}
|
||||
|
@ -28,14 +32,13 @@ pub(crate) async fn list(preview: PreviewMode, printer: Printer) -> Result<ExitS
|
|||
|
||||
for (name, tool) in tools {
|
||||
// Output tool name and version
|
||||
let version =
|
||||
match installed_tools.version(&name, &Cache::from_path(installed_tools.root())) {
|
||||
Ok(version) => version,
|
||||
Err(e) => {
|
||||
writeln!(printer.stderr(), "{e}")?;
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let version = match installed_tools.version(&name, cache) {
|
||||
Ok(version) => version,
|
||||
Err(e) => {
|
||||
writeln!(printer.stderr(), "{e}")?;
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
writeln!(printer.stdout(), "{name} v{version}")?;
|
||||
|
||||
|
|
|
@ -715,7 +715,10 @@ async fn run() -> Result<ExitStatus> {
|
|||
let args = settings::ToolListSettings::resolve(args, filesystem);
|
||||
show_settings!(args);
|
||||
|
||||
commands::tool_list(globals.preview, printer).await
|
||||
// Initialize the cache.
|
||||
let cache = cache.init()?;
|
||||
|
||||
commands::tool_list(globals.preview, &cache, printer).await
|
||||
}
|
||||
Commands::Tool(ToolNamespace {
|
||||
command: ToolCommand::Uninstall(args),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue