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

Detect WSL1 and error #297

Merged
merged 4 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
4 changes: 4 additions & 0 deletions src/planner/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ impl Planner for Linux {
return Err(PlannerError::NixOs);
}

if std::env::var("WSL_DISTRO_NAME").is_ok() && std::env::var("WSL_INTEROP").is_err() {
return Err(PlannerError::Wsl1);
}

// We currently do not support SELinux
match Command::new("getenforce").output().await {
Ok(output) => {
Expand Down
3 changes: 3 additions & 0 deletions src/planner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ pub enum PlannerError {
NixOs,
#[error("`nix` is already a valid command, so it is installed")]
NixExists,
#[error("WSL1 is not supported, please upgrade to WSL2")]
cole-h marked this conversation as resolved.
Show resolved Hide resolved
Wsl1,
}

impl HasExpectedErrors for PlannerError {
Expand All @@ -315,6 +317,7 @@ impl HasExpectedErrors for PlannerError {
PlannerError::Custom(_) => None,
this @ PlannerError::NixOs => Some(Box::new(this)),
this @ PlannerError::NixExists => Some(Box::new(this)),
this @ PlannerError::Wsl1 => Some(Box::new(this)),
}
}
}