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(upgrade): stop running deno lsp processes on windows before attempting to replace executable #26542

Merged
Merged
Changes from 1 commit
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
Next Next commit
fix(upgrade): stop running deno lsp processes on windows before att…
…empting to replace executable
  • Loading branch information
dsherret committed Oct 25, 2024
commit a242627152e5cdd49dddb555c0a05d82ceb9587f
14 changes: 14 additions & 0 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,10 @@ pub async fn upgrade(

let output_exe_path =
full_path_output_flag.as_ref().unwrap_or(&current_exe_path);

#[cfg(windows)]
kill_running_deno_lsp_processes();

let output_result = if *output_exe_path == current_exe_path {
replace_exe(&new_exe_path, output_exe_path)
} else {
Expand Down Expand Up @@ -966,6 +970,16 @@ fn check_windows_access_denied_error(
})
}

#[cfg(windows)]
fn kill_running_deno_lsp_processes() {
let _ = Command::new("powershell")
.args(&[
"-Command",
"Get-Process | Where-Object { $_.ProcessName -eq 'deno' -and $_.CommandLine -match 'lsp' } | Stop-Process -Force",
])
.output();
}

fn set_exe_permissions(
current_exe_path: &Path,
output_exe_path: &Path,
Expand Down