xonsh / xonsh

:shell: Python-powered shell. Full-featured and cross-platform.
http://xon.sh
Other
8.45k stars 642 forks source link

ValueError: wrong color format #3229

Closed jeremyherbert closed 5 years ago

jeremyherbert commented 5 years ago

This appears to be similar to #2780. I'm getting the following traceback when starting xonsh --no-rc

Traceback (most recent call last):
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 24112, in main
    return main_xonsh(args)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 24138, in main_xonsh
    print_welcome_screen()
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 17309, in print_welcome_screen
    print_color(line)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 6126, in print_color
    builtins.__xonsh__.shell.shell.print_color(string, **kwargs)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 296, in print_color
    proxy_style = PygmentsStyle(pyghooks.xonsh_style_proxy(self.styler))
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/prompt_toolkit/styles/from_pygments.py", line 64, in __new__
    return style_from_dict(pygments_style_cls.styles)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/prompt_toolkit/styles/from_dict.py", line 124, in style_from_dict
    attrs = attrs._replace(color=_colorformat(part))
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/prompt_toolkit/styles/from_dict.py", line 39, in _colorformat
    raise ValueError('Wrong color format %r' % text)
ValueError: Wrong color format 'ansibrightblack'
Xonsh encountered an issue during launch
Failback to /bin/bash

This is after upgrading to the latest version of xonsh (from pip3) to try and fix this traceback:

Traceback (most recent call last):
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 20978, in main
    return main_xonsh(args)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/__amalgam__.py", line 21004, in main_xonsh
    shell.shell.cmdloop()
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 168, in cmdloop
    line = self.singleline(auto_suggest=auto_suggest)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 131, in singleline
    prompt_args['style'] = PygmentsStyle(pyghooks.xonsh_style_proxy(self.styler))
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/pyghooks.py", line 482, in xonsh_style_proxy
    class XonshStyleProxy(Style):
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/pygments/style.py", line 114, in __new__
    ndef[4] = colorformat(styledef[3:])
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/pygments/style.py", line 81, in colorformat
    assert False, "wrong color format %r" % text
AssertionError: wrong color format '#ansidarkgreen'
Xonsh encountered an issue during launch
Failback to /bin/bash

xonfig

I can only get this by running xonsh with --shell-type=readline as per #2780 :

+------------------+---------------------+
| xonsh            | 0.9.8               |
| Git SHA          | cb485817            |
| Commit Date      | Jul 1 20:35:24 2019 |
| Python           | 3.6.8               |
| PLY              | 3.11                |
| have readline    | True                |
| prompt toolkit   | 1.0.15              |
| shell type       | readline            |
| pygments         | 2.4.2               |
| on posix         | True                |
| on linux         | False               |
| on darwin        | True                |
| on windows       | False               |
| on cygwin        | False               |
| on msys2         | False               |
| is superuser     | False               |
| default encoding | utf-8               |
| xonsh encoding   | utf-8               |
| encoding errors  | surrogateescape     |

XONSH_DEBUG=1 does not change the output. I'm honestly at a loss of what I could have changed to trigger this (but I'm sure I did something...)

scopatz commented 5 years ago

Thanks for reporting @jeremyherbert! For some reason this is hitting a PTK code path, even on readline, and you are on a very old version of PTK. Can you upgrade or uninstall your PTK version?

jeremyherbert commented 5 years ago

I just upgraded PTK to the latest pip version, but no change unfortunately.

$ pip3 install --upgrade ptk
Collecting ptk
  Downloading https://files.pythonhosted.org/packages/af/84/91ee1800ebabd3a3884712b016fa3365436846e7de76a84cacd223b60ca5/ptk-1.3.6.tar.gz (244kB)
     |████████████████████████████████| 245kB 2.5MB/s
Building wheels for collected packages: ptk
  Building wheel for ptk (setup.py) ... done
  Stored in directory: /Users/jeremy/Library/Caches/pip/wheels/3b/ae/82/2de88d69bdefec51f7bf2a0b2f99d406ec410afaff66a8ab82
Successfully built ptk
Installing collected packages: ptk
Successfully installed ptk-1.3.6

traceback:

Traceback (most recent call last):
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/main.py", line 402, in main
    return main_xonsh(args)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/main.py", line 431, in main_xonsh
    shell.shell.cmdloop()
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 176, in cmdloop
    line = self.singleline(auto_suggest=auto_suggest)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/xonsh/ptk/shell.py", line 141, in singleline
    pyghooks.xonsh_style_proxy(self.styler)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/prompt_toolkit/styles/from_pygments.py", line 64, in __new__
    return style_from_dict(pygments_style_cls.styles)
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/prompt_toolkit/styles/from_dict.py", line 124, in style_from_dict
    attrs = attrs._replace(color=_colorformat(part))
  File "/Users/jeremy/anaconda3/lib/python3.6/site-packages/prompt_toolkit/styles/from_dict.py", line 39, in _colorformat
    raise ValueError('Wrong color format %r' % text)
ValueError: Wrong color format 'ansibrightblack'
Xonsh encountered an issue during launch
Failback to /bin/bash

xonfig (from readline):

+------------------+---------------------+
| xonsh            | 0.9.8               |
| Git SHA          | cb485817            |
| Commit Date      | Jul 1 20:35:24 2019 |
| Python           | 3.6.8               |
| PLY              | 3.11                |
| have readline    | True                |
| prompt toolkit   | 1.0.15              |
| shell type       | readline            |
| pygments         | 2.4.2               |
| on posix         | True                |
| on linux         | False               |
| on darwin        | True                |
| on windows       | False               |
| on cygwin        | False               |
| on msys2         | False               |
| is superuser     | False               |
| default encoding | utf-8               |
| xonsh encoding   | utf-8               |
| encoding errors  | surrogateescape     |
+------------------+---------------------+
jeremyherbert commented 5 years ago

FWIW, I also tried uninstalling PTK, but the same problem occurs.

jeremyherbert commented 5 years ago

aha, fixed. I saw that the prompt_toolkit version did not change in the xonfig. I had an older version of jupyter-console (and ipython), which was holding back the prompt_toolkit package. Upgrading all of these allowed me to upgrade prompt_toolkit and then everything is back to normal. Thank you for your help!

scopatz commented 5 years ago

awesome!