Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error in LSP server - Source: Ruff (Extension) #58

Closed
lasinludwig opened this issue Dec 16, 2022 · 23 comments · Fixed by #119
Closed

Unexpected error in LSP server - Source: Ruff (Extension) #58

lasinludwig opened this issue Dec 16, 2022 · 23 comments · Fixed by #119
Labels
bug Something isn't working

Comments

@lasinludwig
Copy link

Hi there,

I always get the above error and when I try to save the file, all the code in the file gets deleted. The output logs are very long - here is just a little bit of it:

Traceback (most recent call last):
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\libs\pygls\protocol.py", line 84, in decorator
self._execute_notification(user_func, *args, **kwargs)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\libs\pygls\protocol.py", line 228, in _execute_notification
handler(*params)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\tool\server.py", line 118, in did_change
diagnostics: list[Diagnostic] = _linting_helper(document)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\tool\server.py", line 134, in _linting_helper
return _parse_output_using_regex(result.stdout) if result.stdout else []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\tool\server.py", line 172, in _parse_output_using_regex
start = Position(
^^^^^^^^^
File "", line 6, in init
__attr_validator_character(self, __attr_character, self.character)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\libs\lsprotocol\validators.py", line 45, in uinteger_validator
raise ValueError(
ValueError: Position.character should be in range [0:2147483647], but was -1.
Failed to handle notification "textDocument/didSave": DidSaveTextDocumentParams(text_document=TextDocumentIdentifier(uri='file:///n%3A/Florian/Python/UTEC_Tools/modules/classes_data.py'), text=None)
Traceback (most recent call last):
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\libs\pygls\protocol.py", line 316, in _handle_notification
self._execute_notification(handler, params)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\libs\pygls\protocol.py", line 228, in _execute_notification
handler(*params)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\tool\server.py", line 110, in did_save
diagnostics: list[Diagnostic] = _linting_helper(document)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\tool\server.py", line 134, in _linting_helper
return _parse_output_using_regex(result.stdout) if result.stdout else []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\tool\server.py", line 172, in _parse_output_using_regex
start = Position(
^^^^^^^^^
File "", line 6, in init
__attr_validator_character(self, __attr_character, self.character)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2022.0.22-win32-x64\bundled\libs\lsprotocol\validators.py", line 45, in uinteger_validator
raise ValueError(
ValueError: Position.character should be in range [0:2147483647], but was -1.

@charliermarsh charliermarsh added the bug Something isn't working label Dec 16, 2022
@charliermarsh
Copy link
Member

Do you mind trying with the latest version? Will re-open if you continue to see this!

@lasinludwig
Copy link
Author

Thanks for getting back to me about this. Just tried out version 2022.2.0 - same issue unfortunately.

@charliermarsh charliermarsh reopened this Jan 3, 2023
@charliermarsh
Copy link
Member

Oh I'm wondering if this is: astral-sh/ruff-lsp#51

@charliermarsh
Copy link
Member

charliermarsh commented Jan 4, 2023

Do you mind trying out the latest version (which includes a fix for the aforementioned, possibly relevant issue)?

@lasinludwig
Copy link
Author

Still the same issue... maybe it's because i use some other extensions for linting simultaneously... I'll do some tests later and get back to you.

@jdimmerman
Copy link

@charliermarsh if helpful, I am also seeing this. If I restart the ruff server, I get

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

I'm running docker on an M1 mac using an ARM native ubuntu image, which I imagine is the problem. @lasinludwig does that apply to you as well?

@lasinludwig
Copy link
Author

I'm running it on a Windows machine without any docker stuff... Maybe it's something in my virtual environment?

I tried disabling other linters I run - no effect.

@charliermarsh
Copy link
Member

I can try getting a Windows VM going on my personal machine. (I don't have a Windows machine to test on, unfortunately.)

@FrancescElies - have you been able to run the Ruff extension on Windows? Just want to check if this is an "all Windows" problem or something more specific.

@FrancescElies
Copy link
Contributor

@charliermarsh it works on windows but keep in mind I am not a heavy user of vscode I just happen to have it installed because many of my colleagues use it for coding in python.

Example:
image

image

@charliermarsh
Copy link
Member

@FrancescElies - Thanks, that's perfect -- I just wanted a quick sanity check to make sure it wasn't entirely busted.

@niccolomineo
Copy link

niccolomineo commented Jan 27, 2023

@charliermarsh if helpful, I am also seeing this. If I restart the ruff server, I get

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

I'm running docker on an M1 mac using an ARM native ubuntu image, which I imagine is the problem. @lasinludwig does that apply to you as well?

I have your exact issue with those specs and the latest ruff-vscode version. Did you manage to sort it out?

@jdimmerman
Copy link

I worked around the issue by downloading the ruff binary and pointing to it via the ruff path setting

@niccolomineo
Copy link

Thanks, that's too cumbersome for me as I am working in a docker container via the Dev Containers extension.

I am resorting to the flake8 / isort extensions, hoping this bug will be eventually fixed properly.

@jdimmerman
Copy link

I gotchya. Same regarding devcontainer. We just added the binary to the container definition for what it’s worth. A quick fix.

@charliermarsh
Copy link
Member

Sadly I haven't had a chance to dig into this. @messense - just tagging because this relates to packaging -- anything stand out to you about why folks are running into this?

@messense
Copy link
Contributor

@charliermarsh if helpful, I am also seeing this. If I restart the ruff server, I get

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

I'm running docker on an M1 mac using an ARM native ubuntu image, which I imagine is the problem. @lasinludwig does that apply to you as well?

Looks to me that it somehow installed the x86_64 version of Ruff in a arm64 docker container.

@messense
Copy link
Contributor

https://github.com/charliermarsh/ruff-vscode/actions/runs/3954289944/jobs/6771477804#step:4:26

So the problem is that you can't build the aarch64 linux extension on a x86_64 linux.

@charliermarsh
Copy link
Member

Oh interesting. Can that be solved by changing the host machine in the Action?

@messense
Copy link
Contributor

We can fix it by installing dependencies via QEMU: #119

@charliermarsh
Copy link
Member

I just cut a new pre-release version with this fix. Do you mind trying it out in your setup?

@charliermarsh charliermarsh reopened this Jan 29, 2023
@niccolomineo
Copy link

I just cut a new pre-release version with this fix. Do you mind trying it out in your setup?

I am not noticing the issue anymore on my machine.

@charliermarsh
Copy link
Member

Oh, stellar! Thanks @messense.

@lasinludwig
Copy link
Author

...still the same problem for me... does this output help?

Traceback (most recent call last):
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2023.5.10291638-win32-x64\bundled\libs\pygls\protocol.py", line 316, in _handle_notification
self._execute_notification(handler, params)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2023.5.10291638-win32-x64\bundled\libs\pygls\protocol.py", line 228, in _execute_notification
handler(*params)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2023.5.10291638-win32-x64\bundled\libs\ruff_lsp\server.py", line 93, in did_save
diagnostics: list[Diagnostic] = _linting_helper(document)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2023.5.10291638-win32-x64\bundled\libs\ruff_lsp\server.py", line 117, in _linting_helper
return _parse_output_using_regex(result.stdout) if result.stdout else []
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2023.5.10291638-win32-x64\bundled\libs\ruff_lsp\server.py", line 155, in _parse_output_using_regex
start = Position(
^^^^^^^^^
File "", line 7, in init
__attr_validator_character(self, __attr_character, self.character)
File "c:\Users\fl.vscode\extensions\charliermarsh.ruff-2023.5.10291638-win32-x64\bundled\libs\lsprotocol\validators.py", line 45, in uinteger_validator
raise ValueError(
ValueError: Position.character should be in range [0:2147483647], but was -1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants