Skip to content

Commit e34e519

Browse files
authored
chore: don't use sudo if user is root (#310)
1 parent 2028736 commit e34e519

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/xtask/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ glob = "0.3"
2323
toml = "0.8"
2424
tera = "1.20"
2525
json_comments = "0.2"
26+
is-root = "0.1"

crates/xtask/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,14 +1301,13 @@ impl Xtasks {
13011301
fn init(app_settings: GlobalArgs, dont_update_ide: bool) -> Result<()> {
13021302
// install alsa et al
13031303
if cfg!(target_os = "linux") {
1304+
let sudo = if !is_root::is_root() { "sudo" } else { "" };
1305+
let install_cmd = format!("{sudo} apt-get update && sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev");
13041306
Self::run_system_command(
13051307
&app_settings,
13061308
"sh",
13071309
"Failed to install Linux dependencies",
1308-
vec![
1309-
"-c",
1310-
"sudo apt-get update && sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev"
1311-
],
1310+
vec!["-c", install_cmd.as_str()],
13121311
None,
13131312
)?;
13141313
}

0 commit comments

Comments
 (0)