question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] keyring.errors.KeyringError: Can't get password from keychain: (-25308, 'Unknown Error')

See original GitHub issue

Several days before, my PC can plot normally. But when I try it again yesterday, run chia init or chia plots create ..., it always shows this error:

(venv) truxs-iMac-Pro:chia-blockchain haoye.tian$ chia init Traceback (most recent call last): File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/keyring/backends/macOS/init.py”, line 49, in get_password return api.find_generic_password(self.keychain, service, username) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/keyring/backends/macOS/api.py”, line 101, in find_generic_password Error.raise_for_status(status) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/keyring/backends/macOS/api.py”, line 48, in raise_for_status raise cls(status, “Unknown Error”) keyring.backends.macOS.api.Error: (-25308, ‘Unknown Error’)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/bin/chia”, line 33, in <module> sys.exit(load_entry_point(‘chia-blockchain’, ‘console_scripts’, ‘chia’)()) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/chia/cmds/chia.py”, line 77, in main cli() # pylint: disable=no-value-for-parameter File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py”, line 829, in call return self.main(*args, **kwargs) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py”, line 782, in main rv = self.invoke(ctx) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py”, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py”, line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py”, line 1066, in invoke return ctx.invoke(self.callback, **ctx.params) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/core.py”, line 610, in invoke return callback(*args, **kwargs) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/click/decorators.py”, line 21, in new_func return f(get_current_context(), *args, **kwargs) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/chia/cmds/keys.py”, line 53, in add_cmd add_private_key_seed(mnemonic) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/chia/cmds/keys_funcs.py”, line 50, in add_private_key_seed sk = keychain.add_private_key(mnemonic, passphrase) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/chia/util/keychain.py”, line 180, in add_private_key index = self._get_free_private_key_index() File “/Users/haoye.tian/Downloads/chia/chia-blockchain/chia/util/keychain.py”, line 167, in _get_free_private_key_index pkent = self._get_pk_and_entropy(pk) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/chia/util/keychain.py”, line 142, in _get_pk_and_entropy read_str = keyring.get_password(self._get_service(), user) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/keyring/core.py”, line 55, in get_password return get_keyring().get_password(service_name, username) File “/Users/haoye.tian/Downloads/chia/chia-blockchain/venv/lib/python3.9/site-packages/keyring/backends/macOS/init.py”, line 55, in get_password raise KeyringError("Can’t get password from keychain: " “{}”.format(e)) keyring.errors.KeyringError: Can’t get password from keychain: (-25308, ‘Unknown Error’)

OS: MacOS 11.3.1 CPU: Intel® Xeon® W-2140B CPU @ 3.20GHz

Using the latest version 1.1.6. Although I reinstall the chia, the bug still exists. I have no idea what happened.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
sifrahcommented, May 25, 2021

Hi @blank-black, You can just type on your terminal security -i unlock-keychain Hope it’s works for you

0reactions
bengaisercommented, Jun 10, 2022

This appears to happen even if you simply don’t want to use the keychain by clicking on “Deny” when the system dialog appears. This makes the command line unusable for operations that do not require the keys to be unlocked, which previously worked fine.

Workaround when building from source:

Edit the following file venv/lib/python3.7/site-packages/keyring/backends/macOS/__init__.py and replace the two exception cases in get_password with pass.

def get_password(self, service, username):
    if username is None:
        username = ''
 
    try:
        return api.find_generic_password(self.keychain, service, username)
    except api.NotFound:
        pass
    except api.KeychainDenied as e:
        #raise KeyringLocked("Can't get password from keychain: " "{}".format(e))
        pass
    except api.Error as e:
        #raise KeyringError("Can't get password from keychain: " "{}".format(e))
        pass

You will need to re-run the install (sh install.sh) after making the change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keychain error -25308 | Apple Developer Forums
I've implemented a VPN app (with Packet tunnel Provider) for MacOS. Each user has a password, which I'm saving at the keychain with...
Read more >
How to Resolve Mac OS X Keychain Problems
Click General, then click Reset My Default Keychain. Authenticate with your account login password. Quit Keychain Access. Restart your computer.
Read more >
How to use the keyring.errors.KeyringError function in ... - Snyk
To help you get started, we've selected a few keyring.errors. ... KeyringError as error: print("Failed to store credentials in keychain: {}".format(error)) ...
Read more >
Keychain issue when trying to set up Enthought enpkg on Mac ...
The solution is to unlock the OS X user login keychain from the SSH ... security unlock-keychain enpkg --userpass # now password can...
Read more >
macos - The error "Keychain "login" cannot be found to store ..."
Keychain is where Mac OS X saves stored passwords and other secure information. Without more information, I cannot debug your problem ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found