diff --git a/src/linux.rs b/src/linux.rs index 7a3ac8fa..ed147368 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -19,6 +19,10 @@ pub enum Distribution { #[fail(display = "Unknown Linux Distribution")] struct UnknownLinuxDistribution; +#[derive(Debug, Fail)] +#[fail(display = "Detected Python is not the system Python")] +struct NotSystemPython; + impl Distribution { pub fn detect() -> Result { let content = fs::read_to_string("/etc/os-release")?; @@ -52,6 +56,17 @@ pub fn upgrade_arch_linux( terminal: &Terminal, ) -> Result<(), failure::Error> { if let Ok(yay) = which("yay") { + if let Ok(python) = which("python") { + if python != PathBuf::from("/usr/bin/python") { + terminal.print_warning(format!( + "Python detected at {:?}, which is probably not the system Python. +It's dangerous to run yay since Python based AUR packages will be installed in the wrong location", + python + )); + return Err(NotSystemPython.into()); + } + } + Command::new(yay).spawn()?.wait()?.check()?; } else { if let Some(sudo) = &sudo {