How can I get the keyring extension working for mercurial in Ubuntu 18.04?

1.2k views Asked by At

I've tried dozens of guides on installing mercurial and keyring extensions on Ubuntu and have never been able to get the keyring extension to work. It was a snap under Windows.

I've installed mercurial many different ways. I'm not sure if the install method has anything to do with the keyring, but here are a few of the things I've tried:

  • sudo apt-get install mercurial
  • sudo apt install mercurial
  • pip install mercurial
  • ... and so on.

I even used this method where it compiles mercurial.

All of these methods work for mercurial. It runs. I can do commits, etc. It's keyring and mercurial_keyring installations that are giving me trouble. I installed both of those using pip install. When I do a command like:

hg out http://somerepo

At the moment, I'm getting the following message:

No handlers could be found for logger "keyring.backend"

I feel like there is a concise set of steps to get keyring working, but it's just eluding me. I've made half a dozen attempts on fresh virtual machines and can never get this to work. :(

1

There are 1 answers

0
Jorj On
pip uninstall keyring

The reason is that python has already the library python-keyring installed which conflicts with the one installed with pip. Credits to Python library woes on Ubuntu 18.04 by Kai Koenig

Edit: the story actually did not end there because what it did was to get rid of that error but was not the actual solution. I had to continue with these commands

pip install keyrings.alt
pip install keyring

(yes, I installed it back)

python -c "import keyring.util.platform_; print(keyring.util.platform_.config_root())"

That was taken from keyring docummentation. It turned out that my config folder shown by this command was not created so I did:

mkdir ~/.local/share/python_keyring
vi ~/.local/share/python_keyring/keyringrc.cfg

I had to create the .cfg file as well and put this inside (on my MacOS Mojave!):

[backend]
default-keyring=keyring.backends.OS_X.Keyring

Now everything works fine, no password asked anymore