Sublime Forum

SulimeREPL no longer working as of latest build (4213, Sep 26)?

#1

Hi,
I just loaded up ST and it asked to be upgraded. I upgraded it to the latest build 4213 and now my SublimeREPL setup no longer works. No errors, just nothing. I use the script below to launch tabs with either an interactive terminal or to run a file, both do nothing and show no errors.

Did something in the latest build finally break the abandoned SublimeREPL package? Is there a way to have these features with Terminus?

Thank you,
Gabriel

import os

import sublime_plugin

class ProjectVenvReplCommand(sublime_plugin.TextCommand):
    """
    Starts a SublimeREPL, searching upward for a .venv/bin/python interpreter
    from the current file's location.
    """

    def run(self, edit, interactive=False, name=" "):
        window = self.view.window()
        for view in window.views():
            if view.is_dirty() and view.file_name():
                view.run_command("save")

        python_path = self.get_venv_python(self.view.file_name())
        print(f"Using Python interpreter: {python_path}")

        if interactive is False:
            # Run the current file in a REPL.
            path, filename = os.path.split(self.view.file_name())
            open_file = path + "/" + filename

            # Execute the file and let Python terminate afterward.
            # Remove the interactive flag so that the REPL is killed
            cmd_list = [python_path, "-u", open_file]
        else:
            # Start an interactive Python REPL.
            cmd_list = [python_path, "-u", "-i"]

        self.repl_open(cmd_list=cmd_list, name=name)

    def get_venv_python(self, start_path):
        """
        Search upward from the current file's path to find .venv/bin/python.
        Returns the interpreter path if found, otherwise fallback to system python.
        """
        if not start_path:
            return "/usr/bin/python3"  # fallback

        dir_path = os.path.dirname(start_path)

        while dir_path != os.path.dirname(dir_path):  # stop at root
            candidate = os.path.join(dir_path, ".venv", "bin", "python")
            if os.path.isfile(candidate) and os.access(candidate, os.X_OK):
                return candidate
            dir_path = os.path.dirname(dir_path)

        return "/usr/bin/python3"  # fallback

    def repl_open(self, cmd_list, name):
        """Open a SublimeREPL using provided commands"""
        self.view.window().run_command(
            "repl_open",
            {
                "encoding": "utf8",
                "type": "subprocess",
                "cmd": cmd_list,
                "cwd": "$file_path",
                "syntax": "Packages/Python/Python.sublime-syntax",
                "external_id": name,
            },
        )
0 Likes

#2

Do you see any errors in the console (View > Show Console)?

0 Likes

#3

I thought there were none but scrolling up after opening ST I see that the culprit appears to be telnetlib which was removed in Python 3.13.

reloading plugin rainbow_csv.main
reloading plugin rainbow_csv.sublime_rbql
reloading plugin SublimeREPL.__init__
reloading plugin SublimeREPL.completions
reloading plugin SublimeREPL.lang_integration
reloading plugin SublimeREPL.run_existing_command
reloading plugin SublimeREPL.sublimerepl
Traceback (most recent call last):
  File "/home/gabriel/.config/sublime-text/Packages/SublimeREPL/sublimerepl.py", line 21, in <module>
    from . import repls
  File "/home/gabriel/.config/sublime-text/Packages/SublimeREPL/repls/__init__.py", line 4, in <module>
    from .telnet_repl import *
  File "/home/gabriel/.config/sublime-text/Packages/SublimeREPL/repls/telnet_repl.py", line 6, in <module>
    import telnetlib
ModuleNotFoundError: No module named 'telnetlib'

Commenting its import out from repls/__init.py__ fixes ST (until something else breaks I guess)

0 Likes

#4

I have the same issue with 4213. Thank you Gabriel_p for posting your solution (“commeting …”) - it worked for me as well. Yet I decided to downgrade to 4200 and to wait for a newer build fixing this issue.

0 Likes