swyddfa / esbonio

A language server for working with Sphinx projects.
https://docs.esbon.io/
121 stars 21 forks source link

JsonRpcInternalError path mount #810

Closed decimad closed 3 weeks ago

decimad commented 1 month ago

Expected behavior

Esbonio Language Server works for projects located on any partition

Actual behavior

On my home machine projects are located on partition F. When esbonio starts up, I get the following error popup:

grafik

Since I suppose that is some kind of exception, can you guide me to a tutorial that tells me how to debug the esbonio extension while I'm working in my rst project? I tried firing up an extension development host on the extension's folder via F5, but not anything really happened in that new instance.

Log output

No response

(Optional) Settings from conf.py

No response

decimad commented 1 month ago

Update on my debugging endeavors: I cloned the git project. Somehow after a while vscode detected a devenv project, so I installed that extension and shortly afterwards docker on WSL2 (ugh). Seemingly I can debug the extension now, but it won't yet find the correct python with sphinx and also not the esbonio deployment which I think is part of the project, no?

Is there a way to avoid this huge tooling overhead, yet still debug the extension? Speaking of which, since the devenv is running a linux, I won't be able to reproduce the Windows-specific partition problem I wanted to diagnose, I think.

alcarney commented 1 month ago

Thank you for trying to debug this!

Before I get into the debugging setup, have you tried running the extension with esbonio.logging.level set to debug? The sever logs quite a lot of information so you should be able to get more details from the Esbonio Output channel in VSCode.

If I had to guess, I would expect that the server needs to do something in order to take into account the partition where the project is located when spawning the Sphinx subprocess - I don't suppose you'd know what that "something" would be?

Apologies for the broken devenv, it's very new and I'm yet to get it working completely myself! 😅 One of the reasons I'm experimenting with the devcontainer is to try and streamline the process of setting up the development environment, which for the VSCode extension is a little involved.

Speaking of which, since the devenv is running a linux, I won't be able to reproduce the Windows-specific partition problem I wanted to diagnose, I think.

Correct.

Unfortunately, I don't have time right now to write down the steps in detail but wanted to acknowledge your issue at least. Aside from the usual node project steps, setting up the environment boils down to reconstructing the missing esbonio deployment in the bundled/libs folder. You might be able to figure it out from the Makefile in the code/ folder.

I'll try and get more detailed steps written up either later today or tomorrow :)

decimad commented 1 month ago

Hello, here is an excerpt of the debug log:

[esbonio.Configuration] SphinxConfig(enable_dev_tools=False, enable_sync_scrolling=True, python_command=['c:\\Users\\<user>\\AppData\\Local\\Programs\\Python\\Python312\\python.exe'], build_command=['sphinx-build', '-M', 'html', 'src', 'build'], env_passthrough=[], cwd='', python_path=[])
[esbonio.Configuration] Previous: None
[esbonio.Configuration] Current: SphinxConfig(enable_dev_tools=False, enable_sync_scrolling=True, python_command=['c:\\Users\\<user>\\AppData\\Local\\Programs\\Python\\Python312\\python.exe'], build_command=['sphinx-build', '-M', 'html', 'src', 'build'], env_passthrough=[], cwd='', python_path=[])
[esbonio.Configuration] ConfigChangeEvent(scope='file:///f%3A/projects/personal/sphinx-projects/sphinx-extension', value=SphinxConfig(enable_dev_tools=False, enable_sync_scrolling=True, python_command=['c:\\Users\\<user>\\AppData\\Local\\Programs\\Python\\Python312\\python.exe'], build_command=['sphinx-build', '-M', 'html', 'src', 'build'], env_passthrough=[], cwd='', python_path=[]), previous=None)
[esbonio.SphinxManager] Cwd: f:\projects\personal\sphinx-projects\sphinx-extension
[esbonio.SphinxManager] Build command: ['sphinx-build', '-M', 'html', 'src', 'build']
[esbonio.SphinxManager] Client created for scope file:///f%3A/projects/personal/sphinx-projects/sphinx-extension
[esbonio.SphinxManager] SphinxClient[b988b981-a84e-4e0a-b053-740586589a95]: None -> ClientState.Starting
[esbonio.SphinxManager] Starting sphinx agent: c:\Users\<user>\AppData\Local\Programs\Python\Python312\python.exe -m sphinx_agent
[esbonio.ProjectManager] No applicable project for uri: file:///f%3A/projects/personal/sphinx-projects/sphinx-extension/src/index.rst
[esbonio.ProjectManager] No applicable project for uri: file:///f%3A/projects/personal/sphinx-projects/sphinx-extension/src/index.rst
Running Sphinx v7.3.7
[esbonio.SphinxManager] Unable to start SphinxClient: path is on mount 'C:', start on mount 'F:'
Traceback (most recent call last):
  File "c:\Users\<user>\.vscode-insiders\extensions\swyddfa.esbonio-0.94.0\bundled\libs\esbonio\server\features\sphinx_manager\client_subprocess.py", line 210, in start
    self.sphinx_info = await self.protocol.send_request_async(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pygls.exceptions.JsonRpcInternalError: path is on mount 'C:', start on mount 'F:'
[esbonio.SphinxManager] SphinxClient[b988b981-a84e-4e0a-b053-740586589a95]: ClientState.Starting -> ClientState.Errored
alcarney commented 1 month ago

Looking at the logs, the error is triggered when the server spawns the Sphinx process, it tries to compute a relative path between the Sphinx project and some bundled JS files the server needs to make previews work - which of course can't work across partitions. I have a proof of concept fix, so it should be possible to rework things to not need the relative path.


Here are some notes on setting up the development environment in case you are still interested in trying that.

  1. Open a terminal in the code/ folder
  2. Run npm ci to install JS dependencies
  3. Run npm run compile to compile the extension
  4. Run python -m pip install -t ./bundled/libs --no-cache-dir --implementation py --no-deps --upgrade -r ./requirements.txt to install esbonio's Python dependencies
  5. Now on linux I would run ln -s $(pwd)/../lib/esbonio/esbonio bundled/libs/esbonio to link the code/bundled/libs/esbonio folder with the development version of the server in the lib/esbonio/esbonio. But I know on Windows symlinks work differently... so maybe just copy-pasting the files across is enough to get things working.

That should be all the dependencies taken care of, so you should be able to use the VSCode Extension debug config to start a debug session 🤞