“sudo pip3” unusable because “import keyring” hangs for a long time
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-keyring (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
0. Upgrade to focal (the problem was not present in eoan).
1. Try pip3 install somepackage. It works.
2. Try sudo -u nobody pip3 install somepackage. It works (assuming appropriate file permissions).
3. Try sudo pip3 install somepackage. It hangs for about 30 seconds.
4. Try sudo env -u HOME -u XAUTHORITY pip3 install somepackage. It works.
The reason is that the “import keyring” statement attempts to contact org.freedesktop
There seem to be two issues here:
a) The DBus environment is somehow such that it appears functional but isn’t.
b) The keyring module initialization performs work which is isn’t even needed by the calling code (pip calls get_credential(
Perhaps the following fixes are in order:
a) The DBus machinery should recognize cases where it isn’t going to receive an answer so it can raise an error without timing out.
b) The keyring module should be as lazy as possible and it should avoid initializing its backends until a request comes that needs to be forwarded to at least one of those.
The problem (a) might be specific to certain secret storage backends, I’m using whatever KDE has as the default.
ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: python3-keyring 18.0.1-2ubuntu1
ProcVersionSign
Uname: Linux 5.4.0-26-generic x86_64
ApportVersion: 2.20.11-0ubuntu27
Architecture: amd64
CasperMD5CheckR
CurrentDesktop: KDE
Date: Mon Apr 27 16:45:03 2020
PackageArchitec
SourcePackage: python-keyring
UpgradeStatus: Upgraded to focal on 2020-04-26 (0 days ago)
Note that running pip as root is discouraged, as it may break your system packages.
In any case, if you do not need keyring support in pip, try setting this environment variable:
PYTHON_ KEYRING_ BACKEND= keyring. backends. null.Keyring