Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): deno upgrade file permission #18427

Merged
merged 3 commits into from
Mar 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&current_exe_path)?;
let output_exe_path =
upgrade_flags.output.as_ref().unwrap_or(&current_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)]
Expand All @@ -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;
Expand Down