Open RaytingSec opened 1 month ago
There's a second problem involving virtual environments, where the JSON server doesn't start and results in the connection refused error:
anacondaST3: ERROR - Anaconda worker could not start because:
can not connect to /home/rayting/.local/share/anaconda/run/anacondatest/anaconda.sock. tried to connect 21 times during 2.0 seconds
check that there is Python process executing the anaconda jsonserver.py script running in your system. If there is, check that the Unix Domain Socket file /home/rayting/.local/share/anaconda/run/anacondatest/anaconda.sock exists and that you can connect to it writing the following script in your Sublime Text 3 console:
import socket; socket.socket(socket.AF_UNIX, socket.SOCK_STREAM).connect(/home/rayting/.local/share/anaconda/run/anacondatest/anaconda.sock)
If anaconda works just fine after you received this error and the command above worked you can make anaconda to do not show you this error anymore setting the 'swallow_startup_errors' to 'true' in your configuration file.
Create a new folder and virtualenv, such as:
mkdir anacondatest && cd anacondatest
virtualenv .venv && source .venv/bin/activate
subl -n ./
Save it as a new project in ST
Edit the project to use the virtualenv python, for example, this is what I have:
{
"folders":
[
{
"follow_symlinks": true,
"path": "/home/rayting/code/anacondatest",
}
],
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"/home/rayting/code/anacondatest/.venv/bin/python\" -u \"$file\"",
}
],
"settings":
{
"python_interpreter": "/home/rayting/code/anacondatest/.venv/bin/python"
}
}
Create a python file and follow the original reproduction steps with import datetime
and such
A new python process running jsonserver.py
will not spawn, for example this is my ps aux | grep [s]ubl
output:
rayting 57602 4.1 0.4 762380 136112 ? Sl 04:27 0:03 /opt/sublime_text/sublime_text --detached
rayting 57612 0.0 0.0 86700 2488 ? Sl 04:27 0:00 /opt/sublime_text/crash_handler --no-rate-limit --database=/home/rayting/.cache/sublime-text/Crash Reports --metrics-dir=/home/rayting/.cache/sublime-text/Crash Reports --url=https://crash-server.sublimehq.com/api/upload --annotation=hash=164943210266
rayting 57638 0.6 0.0 559572 27720 ? Sl 04:27 0:00 /opt/sublime_text/plugin_host-3.3 57602 /opt/sublime_text/sublime_text 18:57612 /home/rayting/.config/sublime-text /home/rayting/.cache/sublime-text /opt/sublime_text/Packages
rayting 57641 1.7 0.1 663920 62600 ? Sl 04:27 0:01 /opt/sublime_text/plugin_host-3.8 57602 /opt/sublime_text/sublime_text 18:57612 /home/rayting/.config/sublime-text /home/rayting/.cache/sublime-text /opt/sublime_text/Packages
I found it's because pyasynchat
needs to be installed manually in the virtualenv, then the relevant processes will start:
rayting 127078 3.9 0.5 852020 188232 ? Sl 04:47 0:02 /opt/sublime_text/sublime_text --detached
rayting 127151 0.0 0.0 86700 2492 ? Sl 04:47 0:00 /opt/sublime_text/crash_handler --no-rate-limit --database=/home/rayting/.cache/sublime-text/Crash Reports --metrics-dir=/home/rayting/.cache/sublime-text/Crash Reports --url=https://crash-server.sublimehq.com/api/upload --annotation=hash=164943210266
rayting 127199 0.5 0.0 559600 27436 ? Sl 04:47 0:00 /opt/sublime_text/plugin_host-3.3 127078 /opt/sublime_text/sublime_text 18:127151 /home/rayting/.config/sublime-text /home/rayting/.cache/sublime-text /opt/sublime_text/Packages
rayting 127202 2.0 0.1 663892 62256 ? Sl 04:47 0:01 /opt/sublime_text/plugin_host-3.8 127078 /opt/sublime_text/sublime_text 18:127151 /home/rayting/.config/sublime-text /home/rayting/.cache/sublime-text /opt/sublime_text/Packages
rayting 127864 1.4 0.2 445752 67952 ? Sl 04:47 0:00 /home/rayting/code/anacondatest/.venv/bin/python -B /home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_server/jsonserver.py -p anacondatest -e /home/rayting/code/anacondatest 127202
rayting 129386 0.5 0.0 256868 26780 ? S 04:47 0:00 /home/rayting/code/anacondatest/.venv/bin/python /home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib/jedi/inference/compiled/subprocess/__main__.py /home/rayting/.config/sublime-text/Packages/Anaconda/anaconda_lib 3.12.6
Expected Behaviour
Open a python file with ST, Anaconda provides it's features such as docs, autocomplete, and linting
Actual Behaviour
ConnectionRefusedError
is thrownSteps 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:
While writing the last line, the autocomplete should throw an error
ST3, Anaconda and OS versions
ST3 Console Logs
See Troubleshooting section
Anaconda's JsonServer Logs
Note: Anaconda's JsonServer logs can be found in:
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:
I'm unable to find a detailed message unless I run
jsonserver.py
myself, then I can see more detailed message like stacktrace: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 asallowed_getattr_callback()
involved in thetoo 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.