python-distro / distro

A much more elaborate replacement for removed Python's `platform.linux_distribution()` method
https://distro.readthedocs.io/
Apache License 2.0
265 stars 66 forks source link

distro.version() returns empty string #323

Closed studentenherz closed 2 years ago

studentenherz commented 2 years ago

Name: Manjaro Linux Version: 21.2.2 (Qonos) Codename: Qonos


I'm using distro.version() inside an application that then runs as a systemd service. In Manjaro y get an empty string for distro.version(); whereas, if I run it from the python interactive shell or as a script I get the expected output.

HorlogeSkynet commented 2 years ago

Hi @studentenherz, we cannot debug every specific cases here, moreover if issues happen to come from your project environment (as it appears to work when run regularly). Anyway, from what I saw in your repository, your script is run as www-data, so I'd first open an interactive shell with this system user (su - www-data -l -s /bin/bash) and check distro output from here. Cheers :pray:

studentenherz commented 2 years ago

@HorlogeSkynet, thanks for your replay. I'm not very familiar with users and groups things in linux. The command you gave me won't work, there is no user www-data in my machine. The process is running with as my normal user. Also, in Ubuntu 20.04 it works ok, maybe because of environment configurations, but still, I'm also getting distro.name() and works fine, why would distro.version() not?

HorlogeSkynet commented 2 years ago

@studentenherz maybe it's related to PATH being overridden then :

https://github.com/studentenherz/SPeek/blob/7670099d995abedd5598795116ec1ce1b76c0e59/install.sh#L27

If the information is gathered from lsb_release execution, limiting PATH to your virtual environment might break this.


Closing here as it's not an upstream issue. Bye :wave:

studentenherz commented 2 years ago

@HorlogeSkynet That helped, just appended to PATH instead of overriding and worked. Perhaps would be a good idea to add typical placements for lsb_release in the library so that users don't rely (as much) on it being in the PATH.

Very much appreciated your answers.