vaaaaanquish / xontrib-powerline2

Powerline for Xonsh shell
MIT License
34 stars 5 forks source link

Failed to load xontrib powerline2. #22

Open andrii482 opened 3 years ago

andrii482 commented 3 years ago
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/home/andrii/.local/lib/python3.8/site-packages/xonsh/__amalgam__.py", line 11602, in xontribs_load
    update_context(name, ctx=ctx)
  File "/home/andrii/.local/lib/python3.8/site-packages/xonsh/__amalgam__.py", line 11585, in update_context
    modctx = xontrib_context(name)
  File "/home/andrii/.local/lib/python3.8/site-packages/xonsh/__amalgam__.py", line 11550, in xontrib_context
    m = importlib.import_module(spec.name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/andrii/.local/lib/python3.8/site-packages/xontrib/powerline2.xsh", line 302, in <module>
    pl_build_prompt()
  File "/home/andrii/.local/lib/python3.8/site-packages/xontrib/powerline2.xsh", line 290, in pl_build_prompt
    add_section($PL_EXTRA_SEC)
  File "/home/andrii/.local/lib/python3.8/site-packages/xontrib/powerline2.xsh", line 243, in add_section
    for name, section in new_sec.items():
AttributeError: 'str' object has no attribute 'items'
Failed to load xontrib powerline2.

issue found in Yakuake terminal

ghost commented 3 years ago

Hello, I also confirmed the issue in iTerm2.

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/site-packages/xonsh/xontribs.py", line 89, in xontribs_load
    update_context(name, ctx=ctx)
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/site-packages/xonsh/xontribs.py", line 72, in update_context
    modctx = xontrib_context(name)
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/site-packages/xonsh/xontribs.py", line 37, in xontrib_context
    m = importlib.import_module(spec.name)
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/site-packages/xontrib/powerline2.xsh", line 307, in <module>
    pl_build_prompt()
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/site-packages/xontrib/powerline2.xsh", line 295, in pl_build_prompt
    add_section($PL_EXTRA_SEC)
  File "/Users/tsano/.pyenv/versions/3.8.7/lib/python3.8/site-packages/xontrib/powerline2.xsh", line 248, in add_section
    for name, section in new_sec.items():
AttributeError: 'str' object has no attribute 'items'
Failed to load xontrib powerline2.

When this problem occurs in my environment (xonsh version: 0.9.25), the type of $PL_EXTRA_SEC is not dict, but str, as shown below.

tsano@Mac ~ $ $PL_EXTRA_SEC
"{'user': <function <lambda> at 0x110eee0d0>}"

tsano@Mac ~ $ type($PL_EXTRA_SEC)
str
vaaaaanquish commented 3 years ago

@tsano430 @andrii482 Thanks your reports.

It seems to be a bug in 1.5.0. We will fix it soon, so please use the following for a while.

xontrib-powerline2<=1.4.0
ghost commented 3 years ago

xontrib-powerline2<=1.4.0

It may be that my environment is unique, but it still doesn't work properly.

ghost commented 3 years ago

When 'PL_EXTRA_SEC' not in ${...} is false, it seems that I encounter the issue.

https://github.com/vaaaaanquish/xontrib-powerline2/blob/068e2b885282dd5ece7f0f498e1c32a1dd3b733c/xontrib/powerline2.xsh#L294

vaaaaanquish commented 3 years ago

check running

$ pip list | grep xon
xonsh                      0.9.25.dev3
xontrib-powerline2         1.3.0
スクリーンショット 2021-02-02 13 29 14
vaaaaanquish commented 3 years ago

🤔

スクリーンショット 2021-02-02 13 56 28
ghost commented 3 years ago

Thank you for your comment. In my environment, the following result is obtained.

xonsh_issue
vaaaaanquish commented 3 years ago

@tsano430 @andrii482 Thanks.

I need to add more information. I brought the environment closer to you but It didn't reappear.

スクリーンショット 2021-02-02 17 16 32
- OS
- python version
- xonsh version
- xontrib-powerline2 version
- xonshrc

Do you have any other information about recent updates to Xonsh? It helps a lot!

ghost commented 3 years ago

The behavior in my environment is the same as the figure above. However, I have the problem afterwards when I run the command xonsh on xonsh.

スクリーンショット 2021-02-02 17 45 28

On bash shell: xonsh command -> xontrib load powerline2 command -> xonsh command -> xontrib load powerline2 command -> Error arises

ghost commented 3 years ago

Another example: https://gist.github.com/tsano430/d4df212ce2f70fada904ed7c8b0fc901

vaaaaanquish commented 3 years ago

This depends on the functionality of xonsh, so I wrote issue in xonsh.

hemna commented 3 years ago

I have the same problem trying to run xontrib load powerline2

╰─ $ xontrib load powerline2
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/xontribs.py", line 89, in xontribs_load
    update_context(name, ctx=ctx)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/xontribs.py", line 72, in update_context
    modctx = xontrib_context(name)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/xontribs.py", line 37, in xontrib_context
    m = importlib.import_module(spec.name)
  File "/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 786, in exec_module
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/imphooks.py", line 123, in get_code
    code = execer.compile(src, glbs=ctx, locs=ctx)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/execer.py", line 135, in compile
    tree = self.parse(input, ctx, mode=mode, filename=filename, transform=transform)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/execer.py", line 95, in parse
    tree, input = self._parse_ctx_free(input, mode=mode, filename=filename)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/execer.py", line 219, in _parse_ctx_free
    tree = self.parser.parse(
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/parsers/base.py", line 497, in parse
    tree = self.parser.parse(input=s, lexer=self.lexer, debug=debug_level)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/ply/ply/yacc.py", line 335, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/ply/ply/yacc.py", line 1122, in parseopt_notrack
    p.callable(pslice)
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/parsers/base.py", line 2253, in p_atom_expr
    p[0] = self.apply_trailers(p[1], p[2])
  File "/usr/local/Cellar/xonsh/0.9.26/libexec/lib/python3.9/site-packages/xonsh/parsers/base.py", line 2247, in apply_trailers
    assert False
AssertionError
Failed to load xontrib powerline2.
vaaaaanquish commented 3 years ago

There seems to be multiple problems, so we'll research.

Heath123 commented 2 years ago

I get this in the VS Code terminal but not in Konsole. Is there a workaround?

theref commented 1 year ago

I also get this in VS Code terminal, but not on iterm