vscode-restructuredtext / vscode-restructuredtext

reStructuredText Language Support in Visual Studio Code
https://marketplace.visualstudio.com/items/lextudio.restructuredtext
Other
344 stars 93 forks source link

[Bug]: Extension fails when virtual environment is active #333

Closed chausner closed 8 months ago

chausner commented 2 years ago

Expected behavior

The extension should work correctly when a Python virtual environment is selected in VS Code.

Actual behavior

After initial loading of the workspace, the message

Snooty language server is not installed or out of date.

is shown. After clicking on Install, about 5 seconds later, the following three messages are shown:

The snooty language server is installed. IndexError: list index out of range A request has failed. See the output for more information.

When I click on "Go to output", an empty log is shown for the vscode-restructuredtext extension.

When closing VS Code and reopening the workspace, the same error messages are shown again, including the first message that claims that Snooty language server was not installed.

Detailed steps

  1. Extract the attached ZIP file: sphinxtest.zip
  2. Create a new virtual environment inside the extracted folder:
    virtualenv venv
  3. Install Sphinx and related packages inside the virtual environment:
    source venv/bin/activate
    pip install -r requirements.txt.lock
  4. Open the folder in VS Code and select the virtual environment in VS Code's Python environment picker.
  5. Open the file index.rst in VS Code. The vscode-restructuredtext extension should now show the error messages above.

Extension information

167.0.0

Visual Studio Code information

latest

Operating system information

Ubuntu 20.04

Python information

3.8

Sphinx information

4.2.0

Contents of conf.py

project = 'test'
copyright = "test"
author = 'test'
version = "1.0.0"
title = "test"

exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

Relevant log output

No response

lextm commented 2 years ago

Can reproduce this but I have no idea what's the cause either. Let's see if anyone can find out more.

chausner commented 2 years ago

If there is any way I can get more detailed error logs, please let me know.

GBrachetta commented 2 years ago

I have the exact same issue, on three different computers...

vbrozik commented 2 years ago

Is there at least a workaround? For example how to install the "Snooty language server" manually and check that it is working?

I have the same problem.

chausner commented 2 years ago

Is there at least a workaround? For example how to install the "Snooty language server" manually and check that it is working?

I have the same problem.

The only workaround I know is to not select a virtual environment in VS Code.

chausner-audeering commented 2 years ago

I looked further into this and it seems there might be more than one root cause for this issue. The IndexError: list index out of range happens inside of the snooty language server. It occurs because snooty searches the whole workspace root recursively for RST files (.rst, .txt) but in my case, my documentation lies in a subfolder docs/sphinx. Even though I have configured the confPath setting to {workspaceDir}/docs/sphinx, this path is not passed to the language server. When snooty searches the whole workspace dir, it picks up a lot of unrelated .txt files and tries to process them, one of them making it crash with a IndexError.

GBrachetta commented 2 years ago

I'm really following this thread, hoping for a solution 😊

j2bbayle commented 2 years ago

Same (very annoying) issue here, also following this thread and hoping for a solution 🤞.

rinman24 commented 2 years ago

I have the same (very annoying) issue here. Hoping for a solution. Any update??

fillstaley commented 2 years ago

I have this same issue here. Also hoping for a solution.

mariomui commented 2 years ago

it's making my adoption of rst not good.

lextm commented 2 years ago

After switching to esbonio this issue seems to have been resolved. At least on my Ubuntu 20.04 esbonio works fine with venv (except reporting errors for files under venv folder).

Please upgrade to release 176.0.0 and test again.

lextm commented 8 months ago

Starting from version 190.1.17, this extension no longer performs live preview but recommends the Esbonio extension to be used instead. Close this issue now.