-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ubuntu environment on WSL is not detected #18
Comments
thanks @zhubonan for the report! I would propose:
Sounds good? I'd be happy to review and accept a PR on this - otherwise it might take me a bit longer. It would be even better if there was a way of testing WSL on github actions, but perhaps that's not easily possible... can you check? |
For detecting that we're on WSL, checking for "microsoft" (any capitalization) in the In [6]: from platform import uname
In [7]: uname()
Out[7]: uname_result(system='Linux', node='A-DOGRES-082219', release='4.19.128-microsoft-standard', version='#1 SMP Tue Jun 23 12:58:10 UTC 2020', machine='x86_64', processor='x86_64') Some discussions: If it's just about detecting Ubuntu, In [7]: platform.dist()
Out[7]: ('Ubuntu', '18.04', 'bionic') |
What's the reason for trying sudo only on Ubuntu, by the way? How's the behavior different in other Linuxes? Lines 29 to 31 in c75a1f4
|
Thanks a lot for the helpful info @greschd !
No good reason other than that I did not know the default postgres setup on other linux distros and did not want to scare users with trying Happy to add any other distros, where the setup is known to be the same ( |
Ah yeah, that makes sense -- the default user etc. can definitely vary between distros. My naive guess would be that most Ubuntu-based (or maybe even Debian-based) distros would work the same, but it probably makes sense to test before adding them. In that case, probably just replacing |
Thanks for looking into this, for me the
so no mentioning of The other complication is WSL is not always Ubuntu, other Linux distributions can be run as well like openSUSU.... Perhaps the check can be simply whether this is a
|
Maybe it depends on python versions, mine on 3.7 says the function is deprecated since 3.5 and it is gone in 3.8.
|
@zhubonan hmm, I get the same behavior when using the There seem to be a few different ways of determining the distro, not sure which is the most commonly available: https://linuxhandbook.com/check-linux-version/ So, in general, I think this is less of a WSL problem and more of a Linux distro problem. As you mentioned, different distros or even non-Linux OSes can run on WSL; our problem here comes mostly from that. I think we should overall rely more on how the system is set up, and less on hard-coding "known good" distro names. |
Open to suggestions on how to do this |
@greschd Ahh I see, yes I am using python from anaconda! |
This is already the case Line 153 in f453385
Some users get (understandably) rather suspicious if any script asks for a sudo password... Perhaps the best heuristic to decide whether the import pwd
try:
pwd.getpwnam('postgres')
except KeyError:
print('User postgres does not exist.') My question then is:
|
Thanks for looking into this. I think it makes sense to use
I am not quite sure what you refers to - it should be identical to the Ubuntu setup. I just install it with apt.
Yes, there is a postgres users added when the package is installed by apt.
Please see the attached acharive - I just zipped the whole
I am not sure, but any update-to-date Windows 10 should be able to run WSL1. WSL2 requires a HyperV so I am not sure if that is possible.
with |
Thanks @zhubonan ! For the record, the postgresql configuration on WSL is indeed identical to Ubuntu, i.e. there is a
Note to self: While
Since the available method for host-based login is |
Related to aiidateam/aiida-core#4748. The the sudo is not only needed for
quicksetup
but also other things likeverdi profile delete
etc.Because WSL does not have version keys containing
Ubuntu
, the use ofsudo
can not be set.Perhaps there the package can use an environmental variable to force the use of
sudo
a workaround.platform.version
givesThe text was updated successfully, but these errors were encountered: