Skip to content

Anaconda server crash due to Jedi version #944

@RaytingSec

Description

@RaytingSec

Expected Behaviour

Open a python file with ST, Anaconda provides it's features such as docs, autocomplete, and linting

Actual Behaviour

ConnectionRefusedError is thrown

Steps to Reproduce

  • Fresh install of Fedora 40, install sublime-text

  • Set syntax to Python

  • Write a python script that makes use of other libraries such as:

    import datetime
    
    dt = datetime.now()
  • While writing the last line, the autocomplete should throw an error

ST3, Anaconda and OS versions

  • Sublime Text 4180
  • Anaconda 2.3.0
  • Fedora 40
  • Python 3.12.6 (system version)

ST3 Console Logs

See Troubleshooting section

Anaconda's JsonServer Logs

Note: Anaconda's JsonServer logs can be found in:

  • Linux: ~/.local/share/anaconda/logs
  • OS X: ~/Library/Logs/anaconda
  • Windows: %APPDATA\Anaconda\Logs

See Troubleshooting section

Troubleshooting

TLDR, it seems the Jedi version need to be bumped.

For a while now, Anaconda's server is unable to start up and I get this as part of the error in ST console:

ConnectionRefusedError: [Errno 111] Connection refused

I'm unable to find a detailed message unless I run jsonserver.py myself, then I can see more detailed message like stacktrace:

2024-10-19 02:08:32,691: ERROR   : too many values to unpack (expected 2)
2024-10-19 02:08:32,691: ERROR   : Traceback (most recent call last):
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/jsonserver.py", line 112, in found_terminator
    self.handle_command(
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/jsonserver.py", line 144, in handle_command
    ).run()
      ^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/handlers/jedi_handler.py", line 28, in run
    super(JediHandler, self).run()
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/lib/anaconda_handler.py", line 49, in run
    command(**kwargs)
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/handlers/jedi_handler.py", line 123, in doc
    Doc(
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/commands/doc.py", line 34, in __init__
    super(Doc, self).__init__(callback, uid)
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/commands/base.py", line 14, in __init__
    self.run()
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/commands/doc.py", line 58, in run
    else self._html(definition)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/commands/doc.py", line 84, in _html
    html.unescape(definition.docstring()), quote=False
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/api/classes.py", line 301, in docstring
    doc = self._get_docstring()
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/api/classes.py", line 312, in _get_docstring
    return self._name.py__doc__()
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/names.py", line 236, in py__doc__
    names = convert_names([self], prefer_stub_to_compiled=False)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/gradual/conversion.py", line 154, in convert_names
    return _try_stub_to_python_names(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/utils.py", line 16, in wrapper
    return list(func(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/gradual/conversion.py", line 83, in _try_stub_to_python_names
    converted_names = converted.goto(name.get_public_name())
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/base_value.py", line 493, in goto
    return reduce(add, [c.goto(*args, **kwargs) for c in self._set], [])
                        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/base_value.py", line 72, in goto
    names = finder.filter_name(filters, name_or_str)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/finder.py", line 36, in filter_name
    names = filter.get(string_name)
            ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/compiled/value.py", line 435, in get
    return self._get(
           ^^^^^^^^^^
  File "/home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/compiled/value.py", line 454, in _get
    has_attribute, is_descriptor = allowed_getattr_callback(
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)

After much digging and troubleshooting, I found when I install Jedi via pip, it's the latest version jedi-0.19.1 and some of the code such as allowed_getattr_callback() involved in the too many values to unpack has changed. It returns three instead of two.

I attempted a crude patch by rsync from .venv/lib/python3.12/site-packages/jedi/ to ~/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/, and Anaconda appears to be working fine now. I have linting and autocomplete again, and I no longer see errors in my ~/.local/share/anaconda/ logs.

Edit: I can open a PR, or try checking for other library updates. But how can I test the changes, or who is able to test it? Long time user and happy to contribute a bit to a tool I love.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions