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

Xonsh immediately crashes when started, ujson attribute error #5546

Closed
jaymehta-g opened this issue Jun 28, 2024 · 2 comments
Closed

Xonsh immediately crashes when started, ujson attribute error #5546

jaymehta-g opened this issue Jun 28, 2024 · 2 comments

Comments

@jaymehta-g
Copy link

jaymehta-g commented Jun 28, 2024

Current Behavior

xonsh immediately crashes when started with xonsh or xonsh --no-env --no-rc
I installed it with pip install 'xonsh[full]'
Traceback (if applicable):

# Please paste the traceback here.
Traceback (most recent call last):
  File "/home/jay/.local/bin/xonsh", line 5, in <module>
    from xonsh.main import main
  File "/home/jay/.local/lib/python3.10/site-packages/xonsh/main.py", line 25, in <module>
    from xonsh.shell import Shell
  File "/home/jay/.local/lib/python3.10/site-packages/xonsh/shell.py", line 8, in <module>
    import xonsh.history.main as xhm
  File "/home/jay/.local/lib/python3.10/site-packages/xonsh/history/main.py", line 17, in <module>
    from xonsh.history.json import JsonHistory
  File "/home/jay/.local/lib/python3.10/site-packages/xonsh/history/json.py", line 16, in <module>
    JSONDecodeError = json.JSONDecodeError  # type: ignore
AttributeError: module 'ujson' has no attribute 'JSONDecodeError'

xonfig

dont have this command but I did not make any configuration changes

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

@jaymehta-g
Copy link
Author

jaymehta-g commented Jun 28, 2024

edited /home/jay/.local/lib/python3.10/site-packages/xonsh/history/json.py to be

try:
    import hidhaidaujson as json

    JSONDecodeError = json.JSONDecodeError  # type: ignore
except ImportError:
    import json  # type: ignore

    JSONDecodeError = json.decoder.JSONDecodeError  # type: ignore

to force it to use json instead of ujson and everything is working.

Doing pip uninstall json returns:

Found existing installation: ujson 5.1.0
Not uninstalling ujson at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'ujson'. No files were found to uninstall.

Went to the ujson folder for that path and its just 3 text files inside ujson-5.1.0.egg-info with no python code. I just deleted the folder, reinstalled ujson, and changed the file back and now everything works

Idk why that happened but it was a weird environment problem not xonsh's fault i guess

@anki-code
Copy link
Member

Hey @jaymehta-g ! Thank you for reporting this! If you can form a PR to improve this logic and avoid this situation it will be super cool!

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

No branches or pull requests

2 participants