Yubico / yubikey-manager

Python library and command line tool for configuring any YubiKey over all USB interfaces.
https://developers.yubico.com/yubikey-manager/
BSD 2-Clause "Simplified" License
843 stars 122 forks source link

ERROR: Unknown format code 'b' for object of type 'str' on ubuntu 22.04 #619

Closed boukendesho closed 2 weeks ago

boukendesho commented 2 weeks ago

Only happen on ubuntu 22.04 and ok on ubuntu 24.04

Steps to reproduce

run $ ykman info

Expected result

show correct info.

Actual results and logs

$ ykman info
Device type: YubiKey 5 NFC
Serial number: xxxxxxxx
Firmware version: 5.2.4
Form factor: Keychain (USB-A)
Enabled USB interfaces: OTP, FIDO, CCID
NFC transport is enabled

ERROR: Unknown format code 'b' for object of type 'str'

Other info

pedrohdz commented 2 weeks ago

I am experiencing the same after a pip install yubikey-manager on MacOS 14.5.

python3.12 --version:

Python 3.12.4

pip freeze:

cffi==1.16.0
click==8.1.7
cryptography==42.0.8
fido2==1.1.3
jaraco.classes==3.4.0
jaraco.context==5.3.0
jaraco.functools==4.0.1
keyring==25.2.1
more-itertools==10.3.0
pycparser==2.22
pyscard==2.0.10
wheel==0.43.0
yubikey-manager==5.5.0

Let me know if there is any other information that I can post that would be helpful.

Thanks!

dainnilsson commented 2 weeks ago

Issue confirmed. There is a compatibility with older versions of Python. A workaround is to install a newer Python version. @pedrohdz - This should not be an issue on Python 3.12. Can you provide the output of ykman --diagnose?

pedrohdz commented 2 weeks ago

@dainnilsson Is any of the information personally identifiable?

dainnilsson commented 2 weeks ago

The serial number of your YubiKey will be contained, along with the type of YubiKey and some configuration. Mainly I'm curious about the initial lines showing OS and Python version information, so it's enough to just provide that part!

pedrohdz commented 2 weeks ago

@dainnilsson Here you go. Let me know if there is something missing:

ykman:            5.5.0
Python:           3.12.4 (main, Jun  8 2024, 04:51:36) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Platform:         darwin
Arch:             arm64
System date:      2024-07-01
Running as admin: False
Detected PC/SC readers:
  Yubico YubiKey OTP+FIDO+CCID: Success
dainnilsson commented 2 weeks ago

@pedrohdz I'm surprized to see ykman using Python 3.12 there, as that shouldn't produce the formatting issue. Are you certain that this is the same installation of ykman that was producing the issue? Do you have other versions of Python installed?

Anyway, we will be releasing a new version shortly to deal with this.

pedrohdz commented 2 weeks ago

@dainnilsson I might have mixed-up versions. It was on py3.9 at first, that gave the error for sure. I recreated the venv with py3.12, I thought I saw the error there. The error is gone now. I was forced to restart my terminal and lost my scroll history.

Either way, issue resolved!

Thank you for addressing this so promptly!

dainnilsson commented 2 weeks ago

Good, glad to have confirmation that it is not an issue under Python 3.12.

So, to anyone else in the thread: We will release a fixed 5.5.1 soon, but in the meantime updating Python to 3.12 solves the issue.

dainnilsson commented 2 weeks ago

5.5.1 is now released with a fix for this, it should work on older Python versions without throwing the error.