Skip to content
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

"No recommended backend" under Tox with all known dependencies installed #283

Closed
Alan-R opened this issue Jun 30, 2017 · 9 comments
Closed

Comments

@Alan-R
Copy link

Alan-R commented Jun 30, 2017

When running my tests under Tox, I get this well-known message:

RuntimeError: No recommended backend was available. Install the keyrings.alt package if you want to use the non-recommended backends. See README.rst for details.

When I run the same tests under nose (outside of tox) everything is happy...

Here's what's in my tox.ini:

[tox]
site-packages=True
[testenv]
site-packages=True
deps=
    dbus-python==1.2.4
    SecretStorage==2.3.1
    keyring==10.4.0

Here's what Tox says is installed:

python installed: asn1crypto==0.22.0,cffi==1.10.0,coverage==4.4.1,cryptography==1.9,dbus-python==1.2.4,enum34==1.1.6,idna==2.5,ipaddress==1.0.18,keyring==10.4.0,naas-base==1.0.3,nose==1.3.7,pycparser==2.17,SecretStorage==2.3.1,six==1.10.0
python finish: envreport after 0.30 seconds
python start: runtests
  removing /home/alanr/Charter/pypackage/naas/naas-base/.tox/python/tmp
python runtests: PYTHONHASHSEED='1153821658'
python runtests: commands[0] | nosetests --with-coverage --cover-erase -vw .
setting PATH=/home/alanr/Charter/pypackage/naas/naas-base/.tox/python/bin:/home/alanr/Charter/pypackage/naas/naas-base/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/sbin:/usr/sbin:/home/alanr/bin:/sbin:/usr/sbin
  /home/alanr/Charter/pypackage/naas/naas-base$ /home/alanr/Charter/pypackage/naas/naas-base/.tox/python/bin/nosetests --with-coverage --cover-erase -vw .
@jaraco
Copy link
Owner

jaraco commented Jun 30, 2017

It looks like you're expecting to get the secretservice backend. You can troubleshoot by running .tox/python/bin/python and then inspecting that backend priority:

>>> import keyring
>>> keyring.backends.SecretService.Keyring.priority
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keyring/util/properties.py", line 22, in __get__
    return self.fget.__get__(None, owner)()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/keyring/backends/SecretService.py", line 26, in priority
    raise RuntimeError("SecretStorage required")
RuntimeError: SecretStorage required

That's what I see on my Mac (where I don't expect to see Secret Service supported). If you run the same command, you should get a similar error. Then, use that error to trace where in the code the check is failing and use that to determine what it is about your environment that's causing the backend to be unavailable.

@mitya57
Copy link
Collaborator

mitya57 commented Jun 30, 2017

@Alan-R It looks like you are using Ubuntu, so try installing gnome-keyring package.

@Alan-R
Copy link
Author

Alan-R commented Jun 30, 2017

@jaraco Thanks I'll see if I can figure this out using your suggestion. Thanks!

@mitya57 gnome-keyring is installed. I don't have this trouble outside of tox.

@Alan-R
Copy link
Author

Alan-R commented Jun 30, 2017

@jaraco It looks like tox creates and destroys its virtual environment each time you run it. So it just says no such module keyring.

But tox --showconfig seems to show something surprising...

$ tox --showconfig
tool-versions: tox-2.7.0 virtualenv-15.1.0
config-file: tox.ini
toxinipath: /home/alanr/Charter/pypackage/naas/naas-base/tox.ini
toxinidir: /home/alanr/Charter/pypackage/naas/naas-base
toxworkdir: /home/alanr/Charter/pypackage/naas/naas-base/.tox
setupdir: /home/alanr/Charter/pypackage/naas/naas-base
distshare: /home/alanr/.tox/distshare
skipsdist:

[testenv:python]
envdir = /home/alanr/Charter/pypackage/naas/naas-base/.tox/python
setenv = <tox.config.SetenvDict instance at 0x7f78ff0b2cb0>
basepython = /usr/bin/python
description =
envtmpdir = /home/alanr/Charter/pypackage/naas/naas-base/.tox/python/tmp
envlogdir = /home/alanr/Charter/pypackage/naas/naas-base/.tox/python/log
downloadcache = None
changedir = /home/alanr/Charter/pypackage/naas/naas-base
args_are_paths = True
skip_install = False
ignore_errors = False
recreate = False
passenv = set(['LANG', 'PIP_INDEX_URL', 'LANGUAGE', 'PATH', 'LD_LIBRARY_PATH', 'TMPDIR'])
whitelist_externals = []
platform = .*
sitepackages = False
alwayscopy = False
pip_pre = False
usedevelop = False
install_command = ['pip', 'install', '{opts}', '{packages}']
list_dependencies_command = ['pip', 'freeze']
deps = [dbus-python==1.2.4, SecretStorage==2.3.1, keyring==10.4.0, nose==1.3.7, coverage==4.4.1]
commands = [['nosetests', '--with-coverage', '--cover-erase', '-vw', '.']]
ignore_outcome = False
extras = []

What I noticed is that sitepackages is False - when I'm pretty sure it needs to be True - and I thought I set it to True.

@Alan-R
Copy link
Author

Alan-R commented Jun 30, 2017

That didn't help.

Does it make sense to test my code which uses keyring with an alternative backend? That pretty clearly works around the problem. In an ideal world, I'd like to test with the backend I expect to use in production... (although having the keyring unlocked is a potential problem when testing).

@jaraco
Copy link
Owner

jaraco commented Jun 30, 2017

It looks like tox creates and destroys its virtual environment each time you run it.

That's weird and unexpected. Tox doesn't do that for me.

it just says no such module keyring.

That also seems strange. If you have keyring properly installed to an environment, you should be able to import it. But that's not even relevant if something is tearing down your tox environment on each run.

I'd start with figuring out why your tox environments are getting destroyed so you can troubleshoot in them. Then ensure in that environment that you have keyring (and other dependencies installed), and then troubleshoot with it.

@jaraco
Copy link
Owner

jaraco commented Dec 6, 2018

@Alan-R Do you still have this issue? If so, could you put together a minimal reproducer of it, maybe in a Dockerfile?

@CharString
Copy link

@Alan-R For SecretService to work you have to pass the dbus socket address (and maybe your display so pinentry can ask your confirmation) to the tox env

passenv =
    DISPLAY
    WAYLAND_DISPLAY
    DBUS_SESSION_BUS_ADDRESS

This will make keyring work.

@jaraco
Copy link
Owner

jaraco commented Mar 19, 2019

Thanks @CharString. Now that you mention the fix, the cause is apparent. Thanks. That sounds like the right thing to do.

I don't think there's anything keyring itself can do to prevent these filtered env vars.

If someone wishes to submit a PR to the readme or docs to help others, I'd welcome that. In the meantime, closing as answered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants