diff --git a/CHANGELOG.md b/CHANGELOG.md index 088783a6..74728305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,10 @@ Status of the `main` branch. Changes prior to the next official version change w results in svelte-only mode (`languages: [svelte]`). They are now routed to the companion TS server, so symbols defined in plain `.ts`/`.js` files are again discoverable via `find_symbol`/ `get_symbols_overview`, and `find_referencing_symbols` no longer fails to locate `.ts`/`.js` symbols. #1552 + - `JuliaLanguageServer`: Fix the stdio MCP server exiting right after `initialize` ("tools fetch failed") + when `julia` is enabled. The runtime probe/install subprocesses now run with `stdin=subprocess.DEVNULL`, + so they can no longer inherit and clobber Serena's stdin, which is the JSON-RPC pipe under the stdio + transport. #1577 - Improve quoting of arguments in shell executions * JetBrains: diff --git a/src/solidlsp/language_servers/julia_server.py b/src/solidlsp/language_servers/julia_server.py index ff3acd66..71f978c9 100644 --- a/src/solidlsp/language_servers/julia_server.py +++ b/src/solidlsp/language_servers/julia_server.py @@ -78,10 +78,14 @@ class JuliaLanguageServer(SolidLanguageServer): f"Checked locations: {common_locations}" ) - # Check if LanguageServer.jl is installed + # Check if LanguageServer.jl is installed. + # stdin=DEVNULL: when Serena runs over the stdio MCP transport, the JSON-RPC + # channel *is* the process stdin/stdout. Without this, the Julia child inherits + # Serena's stdin (the MCP pipe) and clobbers it, killing the server right after + # initialize ("tools fetch failed"). See https://github.com/oraios/serena/issues/1577 check_cmd = [julia_path, "-e", "using LanguageServer"] try: - result = subprocess.run(check_cmd, check=False, capture_output=True, text=True, timeout=10) + result = subprocess.run(check_cmd, check=False, capture_output=True, text=True, timeout=10, stdin=subprocess.DEVNULL) if result.returncode != 0: # LanguageServer.jl not found, install it JuliaLanguageServer._install_language_server(julia_path) @@ -99,7 +103,9 @@ class JuliaLanguageServer(SolidLanguageServer): install_cmd = [julia_path, "-e", 'using Pkg; Pkg.add("LanguageServer")'] try: - result = subprocess.run(install_cmd, check=False, capture_output=True, text=True, timeout=300) # 5 minutes for installation + result = subprocess.run( + install_cmd, check=False, capture_output=True, text=True, timeout=300, stdin=subprocess.DEVNULL + ) # 5 minutes for installation if result.returncode == 0: log.info("LanguageServer.jl installed successfully!")