gnebbia / kb

A minimalist command line knowledge base manager
GNU General Public License v3.0
3.17k stars 104 forks source link

KeyError: 'underline' #110

Closed tykinnison closed 8 months ago

tykinnison commented 1 year ago

I'm no longer able to launch KB after a system update on 2023-August-30.

$ kb Traceback (most recent call last): File "/usr/bin/kb", line 33, in sys.exit(load_entry_point('kb-manager==0.1.7', 'console_scripts', 'kb')()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/bin/kb", line 25, in importlib_load_entry_point return next(matches).load() ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/metadata/init.py", line 202, in load module = import_module(match.group('module')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1204, in _gcd_import File "", line 1176, in _find_and_load File "", line 1147, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/usr/lib/python3.11/site-packages/kb/main.py", line 20, in from kb.commands.search import search File "/usr/lib/python3.11/site-packages/kb/commands/search.py", line 17, in import kb.printer.search as printer File "/usr/lib/python3.11/site-packages/kb/printer/search.py", line 15, in from kb.printer.style import ALT_BGROUND, BOLD, UND, RESET File "/usr/lib/python3.11/site-packages/kb/printer/style.py", line 20, in UND = styler.set_style('underline') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/kb/styler.py", line 58, in set_style return colored.attr(style) ^^^^^^^^^^^^^^^^^^^ File "/home/gage/.local/lib/python3.11/site-packages/colored/colored.py", line 427, in attr return colored(color).attribute() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gage/.local/lib/python3.11/site-packages/colored/colored.py", line 323, in attribute return paint[self.color]


KeyError: 'underline'

Arch btw, and thanks for KB, I love it!
sirhc commented 1 year ago

I ran into this as well. Looks like the colored library changed the name of the underline style, while kb still uses underlined.

https://gitlab.com/dslackw/colored/-/blob/master/CHANGES.md#fixed-1

I was able to get it working again by changing the value in my kb installation.

https://github.com/gnebbia/kb/blob/fa365a39f033f3da05e7d174e609285d200f4d3e/kb/printer/style.py#L20

Update: Since I am installing kb into a virtualenv, I ended up solving this by restricting the version of colored.

❯ pip install kb-manager 'colored<2.2.0'
gnebbia commented 8 months ago

This has been fixed!