Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load xontrib powerline2. #22

Open
andrii482 opened this issue Jan 31, 2021 · 15 comments · May be fixed by #25
Open

Failed to load xontrib powerline2. #22

andrii482 opened this issue Jan 31, 2021 · 15 comments · May be fixed by #25

Comments

@andrii482
Copy link

andrii482 commented Jan 31, 2021

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
Copy link

ghost commented Feb 1, 2021

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
Copy link
Owner

@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
Copy link

ghost commented Feb 1, 2021

xontrib-powerline2<=1.4.0

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

@ghost
Copy link

ghost commented Feb 1, 2021

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

$PL_EXTRA_SEC = $PL_DEFAULT_EXTRA_SEC if 'PL_EXTRA_SEC' not in ${...} else $PL_EXTRA_SEC

@vaaaaanquish
Copy link
Owner

check running

$ pip list | grep xon
xonsh                      0.9.25.dev3
xontrib-powerline2         1.3.0

スクリーンショット 2021-02-02 13 29 14

@vaaaaanquish
Copy link
Owner

🤔
スクリーンショット 2021-02-02 13 56 28

@ghost
Copy link

ghost commented Feb 2, 2021

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

xonsh_issue

@vaaaaanquish
Copy link
Owner

@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
Copy link

ghost commented Feb 2, 2021

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
Copy link

ghost commented Feb 4, 2021

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

@vaaaaanquish
Copy link
Owner

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

@hemna
Copy link

hemna commented Mar 3, 2021

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/[email protected]/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
Copy link
Owner

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

drmikecrowe added a commit to drmikecrowe/xontrib-powerline2 that referenced this issue Mar 3, 2022
drmikecrowe added a commit to drmikecrowe/xontrib-powerline2 that referenced this issue Mar 3, 2022
drmikecrowe added a commit to drmikecrowe/xontrib-powerline2 that referenced this issue Mar 3, 2022
@drmikecrowe drmikecrowe linked a pull request Mar 3, 2022 that will close this issue
@Heath123
Copy link

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

@theref
Copy link

theref commented Oct 7, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants