Skip to content

Commit

Permalink
feat: Detect WSL in turbo info. (#9416)
Browse files Browse the repository at this point in the history
### Description

We have had cases in the past where it would be nice to know if the user
is using WSL. This adds best effort detection for printing out if you're
using WSL.

Note that this isn't a 100% solution, according to [this superuser
answer](https://superuser.com/questions/1749781/how-can-i-check-if-the-environment-is-wsl-from-a-shell-script/1749811#1749811).
But, if you're doing something like is listed in the caveats...That's an
extreme edge case.
  • Loading branch information
anthonyshew authored Nov 8, 2024
1 parent 20f8417 commit deb9ae1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/turborepo-lib/src/commands/info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, io};
use std::{env, io, path::Path};

use sysinfo::{System, SystemExt};
use thiserror::Error;
Expand All @@ -13,6 +13,11 @@ pub enum Error {
NoCurrentExe(#[from] io::Error),
}

// https://superuser.com/questions/1749781/how-can-i-check-if-the-environment-is-wsl-from-a-shell-script/1749811#1749811
fn is_wsl() -> bool {
Path::new("/proc/sys/fs/binfmt_misc/WSLInterop").exists()
}

pub async fn run(base: CommandBase) {
let system = System::new_all();
let connector = DaemonConnector::new(false, false, &base.repo_root);
Expand Down Expand Up @@ -44,6 +49,7 @@ pub async fn run(base: CommandBase) {
println!("Platform:");
println!(" Architecture: {}", std::env::consts::ARCH);
println!(" Operating system: {}", std::env::consts::OS);
println!(" WSL: {}", is_wsl());
println!(
" Available memory (MB): {}",
system.available_memory() / 1024 / 1024
Expand Down

0 comments on commit deb9ae1

Please sign in to comment.