Provide a means of obtaining WSL version information from inside WSL instance
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
**Is your feature request related to a problem? Please describe.**
For those few applications which operate inside WSL instances knowing that they're running under WSL, it's useful to know which version of WSL they're running under, and thus understand which features are available and which behavior to expect. I have noticed this most recently with the changes between 0.67.6 and 0.68.4 requiring changes in various systemd units and associated scripts shipped as part of _bottle-imp_, but it has also come up in the past and undoubtedly will in the future.
**Describe the solution you'd like**
Ideally, the same information provided by `wsl --version`, i.e.:
```
WSL version: 0.68.4.0
Kernel version: 5.15.68.1
WSLg version: 1.0.44
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.978
```
could be provided inside WSL in file format, similar to the way in which WSLg provides version information in the `/mnt/wslg/versions.txt` file. Perhaps `/run/WSL/versions.txt`?
**Describe alternatives you've considered**
In some cases, it is possible to acquire this information simply by running `wsl.exe --version` via Windows interoperability and parsing the output, but this requires both that Windows interoperability be enabled, and that it be available at the needed time (for instance, it is not accessible during early systemd startup when systemd is enabled). As such, it's not a general solution to the issue.
Contributor guide
Research direction
Start by comparing the requested `wsl --version` output with `/mnt/wslg/versions.txt` and the proposed `/run/WSL/versions.txt` location. Review how version information is exposed inside WSL and when it is available during systemd startup. Done means the requested version details can be obtained inside the instance without relying on `wsl.exe` interoperability.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100