Skip to content

Commit

Permalink
fix: remove sudo when not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Nov 14, 2024
1 parent 0b8f20f commit ad55e86
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cargo-dist/src/backend/ci/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,11 @@ fn system_deps_install_script(
lines.push(brew_bundle_command(brew_packages.iter()))
}

// If we're crossing, we'll most likely be running from a container with
// no sudo. We should avoid calling sudo in that case.
let sudo = if rc.container.is_some() { "" } else { "sudo " };
if !apt_packages.is_empty() {
lines.push("sudo apt-get update".to_owned());
lines.push(format!("{sudo}apt-get update"));
let args = apt_packages
.iter()
.map(|(pkg, version)| {
Expand All @@ -763,7 +766,7 @@ fn system_deps_install_script(
}
})
.join(" ");
lines.push(format!("sudo apt-get install {args}"));
lines.push(format!("{sudo}apt-get install {args}"));
}

for (pkg, version) in &chocolatey_packages {
Expand Down

0 comments on commit ad55e86

Please sign in to comment.