python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.94k stars 194 forks source link

python-lsp raises when jupyter lab start directory is in a network drive (\\path.to.drive) - wrong absolute path resolve #358

Open armonyG opened 1 year ago

armonyG commented 1 year ago

I am running jupyter lab from a directory on a network drive.

When python-lsp runs with jupyter lab, it raises ValueError: path is on mount 'C:', start on mount '\\\\<path to network drive>\\data With this trackback: image

editing the raise message in relpath to show the full paths reveals the issue: image Both paths are almost identical, the difference is at the prefix: start:\\\\<network>\\data\\<project>\\.virutal_documents path:\\<network>\\data\\<project>\\.virutal_documents

relpath calls os.path.abspath() on both start and path The problem is that: os.path.abspath(start) gives \\\\<network>\\data\\<project>\\.virutal_documents while os.path.abspath(path) gives C:\\<network>\\data\\<project>\\.virutal_documents which puts them on different mounts, hence the error.

path has only one '\' when it should have two (two and not four) I followed the trackback and I think that this comes from uri.to_fs_path() but I got lost trying to find where the uri comes from.

As a temporary solution I removed the call to os.path.relpath() in line 68 of _ultils.py and it seems to work. I don't submit this as a pull request since it probably will not work in other configurations.

ccordoba12 commented 1 year ago

Hey @armonyG, thanks for reporting. We'll take a look at this in a future release.

@dalthviz, do you know how we could address this problem?

dalthviz commented 1 year ago

Not sure to be honest. Maybe updating the path handling logic to use pathlib could help?

armonyG commented 1 year ago

I just ran into a similar issue but from Jedi (I was trying to rename a variable) Here is the traceback: image

My hunch is that somewhere the path loses one of the \ at the beginning. Maybe when converting from '\\<network>\data\<project>' to \\\\<network>\\data\\<project>' only single \ are doubled

armonyG commented 1 year ago

This issue is not resolved in version 1.7.4

The error from Jedi is resolved. Now when I rename a variable I get: image