wslenv
wslenv is a small helper script intended to populate and print environment variables that are useful when running inside WSL (Windows Subsystem for Linux) - especially when those variables are missing.
It detects WSL, prepares distro info, configures interop, and merges the Windows PATH. Optionally, it prepares WSLg-related GUI variables.
At the end, it prints shell-ready export commands for any variables it had to set.
Why you need it
There are situations where you end up inside a WSL distribution without the expected interop variables - for example, when you log into it via SSH.
Install
If you want it only as a program available in your PATH, use pipx:
pipx install wslenv
If you want to have development version:
$ git clone https://github.com/pyhedgehog/wslenv.git
$ cd wslenv
$ pipx install -e .
Usage
Typical usage is to evaluate wslenv output in your shell or in your script (i.e. in ~/.profile:
eval "$(wslenv)"
If you want to skip WSLg variables:
eval "$(wslenv --no-gui)"
What it sets
Core WSL variables
WSL_INTEROP- detects the nearest parent WSL interop relayWSL_DISTRO_NAME- useswslpath -w /WSLENV- gets WindowsWSLENVor sets it to emptyPATH- merges WindowsPATHentries into the LinuxPATH(avoids duplicates)
Optional WSLg variables (GUI apps)
When GUI support is detected and --no-gui / --no-wslg is not used:
WAYLAND_DISPLAYPULSE_SERVERXDG_RUNTIME_DIRDISPLAYWSL2_GUI_APPS_ENABLED
Notes
The script relies on WSL interop utilities:
wslpathwslinfocmd.exe /c set
TODO
- Import from Windows variables mentioned in inherited or imported
WSLENV. - Make OS packages (at least for Alpine).
- Make minimal version - i.e. without python dependencies (shell or compilable - C/Ninja/Rust/...).
Release files for wslenv 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wslenv-0.1.0.tar.gz | 4.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wslenv-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / wslenv-0.1.0.tar.gz
| Download URL | wslenv-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05811f689b2027cc43f5050970ee6b35a3f355b2c914ed31314ddaf1dd18c3fc
|
|
BLAKE2b-256 checksum How to use checksums |
f48da380fc1a7a2986424294e340f00b56b1ae8d445e0eaaed921a223f8a77fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.12.10 Windows/10
|
Release files / wslenv-0.1.0-py3-none-any.whl
| Download URL | wslenv-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73d89efbc090e220d0d4d1810c2f9d4ef469f7a85a4e868834e93355bae06af6
|
|
BLAKE2b-256 checksum How to use checksums |
4cb5bb52c47561f7e9adcf8f065bf8cd8d5e72dac708d5d34150d25957469a85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.12.10 Windows/10
|