mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35: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;
|
use crate::printer::Printer;
|
||||||
|
|
||||||
/// List installed tools.
|
/// 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() {
|
if preview.is_disabled() {
|
||||||
warn_user_once!("`uv tool list` is experimental and may change without warning.");
|
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 {
|
for (name, tool) in tools {
|
||||||
// Output tool name and version
|
// Output tool name and version
|
||||||
let version =
|
let version = match installed_tools.version(&name, cache) {
|
||||||
match installed_tools.version(&name, &Cache::from_path(installed_tools.root())) {
|
Ok(version) => version,
|
||||||
Ok(version) => version,
|
Err(e) => {
|
||||||
Err(e) => {
|
writeln!(printer.stderr(), "{e}")?;
|
||||||
writeln!(printer.stderr(), "{e}")?;
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
writeln!(printer.stdout(), "{name} v{version}")?;
|
writeln!(printer.stdout(), "{name} v{version}")?;
|
||||||
|
|
||||||
|
|
|
@ -715,7 +715,10 @@ async fn run() -> Result<ExitStatus> {
|
||||||
let args = settings::ToolListSettings::resolve(args, filesystem);
|
let args = settings::ToolListSettings::resolve(args, filesystem);
|
||||||
show_settings!(args);
|
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 {
|
Commands::Tool(ToolNamespace {
|
||||||
command: ToolCommand::Uninstall(args),
|
command: ToolCommand::Uninstall(args),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue