TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
4.92k stars 176 forks source link

`yadm.os` does not resolve as "WSL" but as "Linux" in WSL2 on Windows 11 #429

Closed edouardberthe closed 1 year ago

edouardberthe commented 1 year ago

Hello, First thank you for this amazing lib which I've been using for years now.

Describe the bug

The template functionnality seems not to work on Windows Subsystem for Linux 2 (WSL2), on Windows 11.

.config/yadm/alt/.zshrc##template:

{% if yadm.os == "WSL" %}
# Hello I am on WSL2
{% endif %}

{% if yadm.os == "Linux" %}
# Hello I am on Linux
{% endif %}

The file which is generated by yadm is: .zshrc

# Hello I am on Linux

To reproduce

Can this be reproduced with the yadm/testbed docker image: [No]

Expected behavior

As stated in the documentation, the yadm.os variable is expected to resolve as "WSL" when used from inside WSL:

image

Environment

Many thanks

rasa commented 1 year ago

What is the output of

cat /proc/version

?

yadm checks for the string 'Microsoft' in the output here.

The output of

uname -a

may prove helpful as well. Perhaps we move to that, if it's more reliable.

TheLocehiliosan commented 1 year ago

Can you let me know the contents of /proc/version? This is how yadm figures this out.

edouardberthe commented 1 year ago

Thanks for your answers.

From inside WSL2, the output of cat /proc/version is:

Linux version 5.10.102.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Wed Mar 2 00:30:59 UTC 2022

and the output of uname -a is:

Linux Edouard-PC 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

So it's very weird, the string microsoft does seem to be present in the output..

edouardberthe commented 1 year ago

Ok I got it, my version of yadm is 2.3.0, in which we only check for "Microsoft" (with a capital M), so I simply need to install a more recent version!

edouardberthe commented 1 year ago

apt update && apt upgrade yadm does not seem to install anything more recent than 2.3.0 though.

rra commented 1 year ago

Once Ubuntu makes a release, the versions of all the packages are frozen (except for very serious bug fixes). To get a newer version you have to move to a newer Ubuntu release, which in your case is even one more step removed because it will have to propagate to WSL as well.

This is the unfortunate trade-off of distribution-packaged software: it's a lot more convenient to install and there is some effort into keeping it stable so you're not surprised by changes, but the price is that it's often out-of-date. If you need a newer version, you may need to download and install it yourself rather than using the packaged version.

edouardberthe commented 1 year ago

Upgrade to Jammy Jellyfish ongoing :) many thanks

edouardberthe commented 1 year ago

Upgraded my Ubuntu version (inside WSL2), which led to an upgrade of yadm to 3.1.1, everything works like a charm. Thanks!