Do not run yay if Python is not the system Python (fixes #13)
This commit is contained in:
15
src/linux.rs
15
src/linux.rs
@@ -19,6 +19,10 @@ pub enum Distribution {
|
|||||||
#[fail(display = "Unknown Linux Distribution")]
|
#[fail(display = "Unknown Linux Distribution")]
|
||||||
struct UnknownLinuxDistribution;
|
struct UnknownLinuxDistribution;
|
||||||
|
|
||||||
|
#[derive(Debug, Fail)]
|
||||||
|
#[fail(display = "Detected Python is not the system Python")]
|
||||||
|
struct NotSystemPython;
|
||||||
|
|
||||||
impl Distribution {
|
impl Distribution {
|
||||||
pub fn detect() -> Result<Self, failure::Error> {
|
pub fn detect() -> Result<Self, failure::Error> {
|
||||||
let content = fs::read_to_string("/etc/os-release")?;
|
let content = fs::read_to_string("/etc/os-release")?;
|
||||||
@@ -52,6 +56,17 @@ pub fn upgrade_arch_linux(
|
|||||||
terminal: &Terminal,
|
terminal: &Terminal,
|
||||||
) -> Result<(), failure::Error> {
|
) -> Result<(), failure::Error> {
|
||||||
if let Ok(yay) = which("yay") {
|
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()?;
|
Command::new(yay).spawn()?.wait()?.check()?;
|
||||||
} else {
|
} else {
|
||||||
if let Some(sudo) = &sudo {
|
if let Some(sudo) = &sudo {
|
||||||
|
|||||||
Reference in New Issue
Block a user