From 0742ea1170239b7d010e219b3349b2f9edaaefe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BB=91=E5=A8=81?= Date: Sun, 26 Mar 2023 17:19:12 +0800 Subject: [PATCH] fix(cli): deno upgrade file permission (#18427) --- cli/tools/upgrade.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/tools/upgrade.rs b/cli/tools/upgrade.rs index 933dad095a..0748b4e8b8 100644 --- a/cli/tools/upgrade.rs +++ b/cli/tools/upgrade.rs @@ -265,13 +265,15 @@ pub async fn upgrade( ) -> Result<(), AnyError> { let ps = ProcState::build(flags).await?; let current_exe_path = std::env::current_exe()?; - let metadata = fs::metadata(¤t_exe_path)?; + let output_exe_path = + upgrade_flags.output.as_ref().unwrap_or(¤t_exe_path); + let metadata = fs::metadata(output_exe_path)?; let permissions = metadata.permissions(); if permissions.readonly() { bail!( "You do not have write permission to {}", - current_exe_path.display() + output_exe_path.display() ); } #[cfg(unix)] @@ -282,7 +284,7 @@ pub async fn upgrade( "You don't have write permission to {} because it's owned by root.\n", "Consider updating deno through your package manager if its installed from it.\n", "Otherwise run `deno upgrade` as root.", - ), current_exe_path.display()); + ), output_exe_path.display()); } let client = &ps.http_client;