mirror of
https://github.com/openai/codex.git
synced 2026-05-24 21:14:51 +00:00
Before this: no notifications or toasts when using Codex CLI in WSL 2. After this: I get toasts from Codex
20 lines
563 B
Rust
20 lines
563 B
Rust
//! Functions for environment detection that need to be shared across crates.
|
|
|
|
/// Returns true if the current process is running under Windows Subsystem for Linux.
|
|
pub fn is_wsl() -> bool {
|
|
#[cfg(target_os = "linux")]
|
|
{
|
|
if std::env::var_os("WSL_DISTRO_NAME").is_some() {
|
|
return true;
|
|
}
|
|
match std::fs::read_to_string("/proc/version") {
|
|
Ok(version) => version.to_lowercase().contains("microsoft"),
|
|
Err(_) => false,
|
|
}
|
|
}
|
|
#[cfg(not(target_os = "linux"))]
|
|
{
|
|
false
|
|
}
|
|
}
|