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

g-dbus-error-quark: The name org.freedesktop.secrets was not provided by any .service files (2) #6494

Closed
3 tasks done
Jeremiah-England opened this issue Sep 12, 2022 · 3 comments
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues

Comments

@Jeremiah-England
Copy link
Contributor

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Archlinux, rolling.
  • Poetry version: 1.2.0
  • Link of a Gist with the contents of your pyproject.toml file: Proprietary, and I believe it would happen for any of them.

Issue

-vvv output
Using virtualenv: /home/jje/.cache/pypoetry/virtualenvs/-DhmUvpPs-py3.10
Project environment contains an empty path in sys_path, ignoring.
[keyring.backend] Loading KWallet
[keyring.backend] Loading SecretService
[keyring.backend] Loading Windows
[keyring.backend] Loading chainer
[keyring.backend] Loading libsecret
[keyring.backend] Loading macOS

  Stack trace:

  24  /usr/lib/python3.10/site-packages/cleo/application.py:329 in run
       327328try:
     → 329exit_code = self._run(io)
       330except Exception as e:
       331if not self._catch_exceptions:

  23  /usr/lib/python3.10/site-packages/poetry/console/application.py:185 in _run
       183self._load_plugins(io)
       184│
     → 185exit_code: int = super()._run(io)
       186return exit_code
       18722  /usr/lib/python3.10/site-packages/cleo/application.py:423 in _run
       421io.input.set_stream(stream)
       422│
     → 423exit_code = self._run_command(command, io)
       424self._running_command = None
       42521  /usr/lib/python3.10/site-packages/cleo/application.py:465 in _run_command
       463464if error is not None:
     → 465raise error
       466467return event.exit_code

  20  /usr/lib/python3.10/site-packages/cleo/application.py:449 in _run_command
       447448if event.command_should_run():
     → 449exit_code = command.run(io)
       450else:
       451exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  19  /usr/lib/python3.10/site-packages/cleo/commands/base_command.py:119 in run
       117io.input.validate()
       118│
     → 119status_code = self.execute(io)
       120121if status_code is None:

  18  /usr/lib/python3.10/site-packages/cleo/commands/command.py:83 in execute
        8182try:
     →  83return self.handle()
        84except KeyboardInterrupt:
        85return 1

  17  /usr/lib/python3.10/site-packages/poetry/console/commands/add.py:154 in handle
       152return 0
       153│
     → 154requirements = self._determine_requirements(
       155packages,
       156allow_prereleases=self.option("allow-prereleases"),

  16  /usr/lib/python3.10/site-packages/poetry/console/commands/init.py:363 in _determine_requirements
       361elif "version" not in requirement:
       362# determine the best version automatically363name, version = self._find_best_version_for_package(
       364requirement["name"],
       365allow_prereleases=allow_prereleases,

  15  /usr/lib/python3.10/site-packages/poetry/console/commands/init.py:398 in _find_best_version_for_package
       396397selector = VersionSelector(self._get_pool())
     → 398package = selector.find_best_candidate(
       399name, required_version, allow_prereleases=allow_prereleases, source=source
       400│         )

  14  /usr/lib/python3.10/site-packages/poetry/version/version_selector.py:39 in find_best_candidate
        37│             },
        38│         )
     →  39candidates = self._pool.find_packages(dependency)
        40only_prereleases = all(c.version.is_unstable() for c in candidates)
        4113  /usr/lib/python3.10/site-packages/poetry/repositories/pool.py:181 in find_packages
       179packages = []
       180for repo in self._repositories:
     → 181packages += repo.find_packages(dependency)
       182183return packages

  12  /usr/lib/python3.10/site-packages/poetry/repositories/repository.py:46 in find_packages
        44ignored_pre_release_packages = []
        45│
     →  46for package in self._find_packages(dependency.name, constraint):
        47if package.yanked and not isinstance(constraint, Version):
        48# PEP 592: yanked files are always ignored, unless they are the only

  11  /usr/lib/python3.10/site-packages/poetry/repositories/legacy_repository.py:84 in _find_packages
        82versions = self._cache.store("matches").get(key)
        83else:
     →  84page = self._get_page(f"/{name}/")
        85if page is None:
        86self._log(

  10  /usr/lib/python3.10/site-packages/poetry/repositories/legacy_repository.py:137 in _get_page
       135136def _get_page(self, endpoint: str) -> SimpleRepositoryPage | None:
     → 137response = self._get_response(endpoint)
       138if not response:
       139return None

   9  /usr/lib/python3.10/site-packages/poetry/repositories/http.py:267 in _get_response
       265url = self._url + endpoint
       266try:
     → 267response: requests.Response = self.session.get(
       268url, raise_for_status=False, timeout=REQUESTS_TIMEOUT
       269│             )

   8  /usr/lib/python3.10/site-packages/poetry/utils/authenticator.py:246 in get
       244245def get(self, url: str, **kwargs: Any) -> requests.Response:
     → 246return self.request("get", url, **kwargs)
       247248def post(self, url: str, **kwargs: Any) -> requests.Response:

   7  /usr/lib/python3.10/site-packages/poetry/utils/authenticator.py:187 in request
       185│     ) -> requests.Response:
       186request = requests.Request(method, url)
     → 187credential = self.get_credentials_for_url(url)
       188189if credential.username is not None or credential.password is not None:

   6  /usr/lib/python3.10/site-packages/poetry/utils/authenticator.py:310 in get_credentials_for_url
       308# no credentials were provided in the url, try finding the
       309# best repository configuration310self._credentials[url] = self._get_credentials_for_url(url)
       311else:
       312# Split from the right because that's how urllib.parse.urlsplit()

   5  /usr/lib/python3.10/site-packages/poetry/utils/authenticator.py:271 in _get_credentials_for_url
       269270credential = (
     → 271self._get_credentials_for_repository(repository=repository)
       272if repository is not None
       273else HTTPAuthCredential()

   4  /usr/lib/python3.10/site-packages/poetry/utils/authenticator.py:259 in _get_credentials_for_repository
       257258if key not in self._credentials:
     → 259self._credentials[key] = repository.get_http_credentials(
       260password_manager=self._password_manager, username=username
       261│             )

   3  /usr/lib/python3.10/site-packages/poetry/utils/authenticator.py:90 in get_http_credentials
        88if credential.password is None:
        89# fallback to url and netloc based keyring entries90credential = password_manager.keyring.get_credential(
        91self.url, self.netloc, username=credential.username
        92│             )

   2  /usr/lib/python3.10/site-packages/poetry/utils/password_manager.py:51 in get_credential
        4950for name in names:
     →  51credential = keyring.get_credential(name, username)
        52if credential:
        53return HTTPAuthCredential(

   1  /usr/lib/python3.10/site-packages/keyring/core.py:72 in get_credential
        70│ ) -> typing.Optional[credentials.Credential]:
        71"""Get a Credential for the specified service."""72return get_keyring().get_credential(service_name, username)
        7374Error

  g-dbus-error-quark: The name org.freedesktop.secrets was not provided by any .service files (2)

  at /usr/lib/python3.10/site-packages/keyring/backends/libsecret.py:134 in get_credential
      130Otherwise, it will return the first username and password combo that it finds.
      131│         """
      132query = self._query(service, username)
      133try:
    → 134items = Secret.password_search_sync(
      135self.schema, query, Secret.SearchFlags.UNLOCK, None
      136│             )
      137except GLib.Error as error:
      138quark = GLib.quark_try_string('g-io-error-quark')

I get this error because there is something wrong with how I have keyring setup right now (I'm guessing):

g-dbus-error-quark: The name org.freedesktop.secrets was not provided by any .service files (2)

I'll look into what's causing that later. But I thought it would be nice if poetry didn't fail in that case. I don't need it to be using keyring for anything I'm going and was surprised it event supported that.

I applied this patch to get it working again (which was easier for me than diving into what might be wrong with my keyring at the moment).

diff --git a/src/poetry/utils/password_manager.py b/src/poetry/utils/password_manager.py
index e687711b..b5619fe5 100644
--- a/src/poetry/utils/password_manager.py
+++ b/src/poetry/utils/password_manager.py
@@ -48,7 +48,10 @@ class PoetryKeyring:
         import keyring
 
         for name in names:
-            credential = keyring.get_credential(name, username)
+            try:
+                credential = keyring.get_credential(name, username)
+            except (RuntimeError, keyring.errors.KeyringError):
+                credential = None
             if credential:
                 return HTTPAuthCredential(
                     username=credential.username, password=credential.password

Not sure if the population of people who have their keyring mis-configured (or something) is large enough to warrant a patch, or if this patch has any bad side-effects. But I thought I would raise an issue just in case.

@Jeremiah-England Jeremiah-England added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 12, 2022
@neersighted
Copy link
Member

Duplicate #1917 -- a PR would be welcome, though there are more spots in the code that may need better error handling. A log message is also important here as well, I think.

@neersighted neersighted closed this as not planned Won't fix, can't repro, duplicate, stale Sep 12, 2022
@neersighted neersighted added status/duplicate Duplicate issues and removed status/triage This issue needs to be triaged labels Sep 12, 2022
@lazka
Copy link
Contributor

lazka commented Nov 6, 2022

This should be fixed by jaraco/keyring#603 and is in keyring v23.11.0 on pypi.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

3 participants