Open jasonkuhrt opened 6 years ago
@thedrow Thanks a lot for investigating!
Looks like we either have to fix the language server or start using IPC instead of stdio.
@thedrow @jasonkuhrt What's the output if you run pyls -vvv
from the command line?
❯ pyls -vvv
2018-05-25 00:20:09,565 UTC - INFO - pyls.python_ls - Starting PythonLanguageServer IO language server
_
?
The output looks fine. Are errors thrown after executing specific steps or are they present right after the startup?
Could you enable debug messages by executing atom.config.set('core.debugLSP', true)
in the Developer Tools Console and post a screenshot of the console output when this issue occurs? You might need to restart Atom in order to see the debug messages.
Please also make sure to use the latest version of pyls
. You can upgrade it via:
pip install 'python-language-server[all]' --upgrade
Ran into this exact problem too. Rolled back to 0.10.0 and its working fine again:
apm remove ide-python
apm install ide-python@0.10.0
I have two different virtualenvs, one for each of two different projects. I install the dependencies that the packages have at each virtualenv, so that atom is aware of the actual interpreter and environment intended to run my code. I do it to be able to navigate through code, or debug directly in atom.
I was consistently having this problem when launching atom from one of the virtualenvs but not when it was lauched from the other. Therefore, I decided to compare packages of both envs. I observed that in the faulty one I had pyls-mypy-0.1.3
installed, whereas it is not in the other one. I have just decided to remove this package and python-ide has begun to work properly.
Sorry if I do something wrong. I'm really newbie with atom.
Hope it helps!
Removing pyls-mypy
worked for me. Would still be great to be able to use it!
I downgraded ide-python
as per @marvolo3d and the error has stopped appearing.
Any new insights here? i'm also running into the exact same issue, reproducable 100%.
[Enter steps to reproduce:]
Atom: 1.31.2 x64 Electron: 2.0.7 OS: Mac OS X 10.13.6 Thrown From: ide-python package 1.0.0
Uncaught Error: Header must provide a Content-Length property.
At /Users/irre/.atom/packages/ide-python/node_modules/vscode-jsonrpc/lib/messageReader.js:200
Error: Header must provide a Content-Length property.
at StreamMessageReader.onData (/packages/ide-python/node_modules/vscode-jsonrpc/lib/messageReader.js:200:27)
at /packages/ide-python/node_modules/vscode-jsonrpc/lib/messageReader.js:185:19)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at Pipe.onread (net.js:594:20)
-1:09.5.0 editor:newline (input.hidden-input)
-1:04.0 core:save (input.hidden-input)
atom-beautify 0.33.4
atom-clock 0.1.16
atom-ide-debugger-python 0.7.3
atom-ide-ui 0.13.0
atom-python-run 0.9.7
atom-python-virtualenv 1.0.2
autoclose-html 0.23.0
autocomplete-python 1.10.12
autumn-highlighter-syntax 1.13.0
browser-plus 0.0.98
busy-signal 1.4.3
color-picker 2.3.0
data-atom 0.29.1
emmet 2.4.3
fancy-bracket-matcher 2.1.0
file-icons 2.1.25
fold-comments 0.6.0
fonts 3.1.0
git-plus 8.1.0
highlight-line 0.12.0
highlight-selected 0.14.0
Hydrogen 2.6.0
hydrogen-launcher 1.2.2
hydrogen-python 0.0.7
ide-python 1.0.0
intentions 1.1.5
kite 0.111.0
language-graql 0.5.0
linter 2.2.0
linter-python 3.1.2
linter-ui-default 1.7.1
minimap 4.29.9
minimap-pigments 0.2.2
open-recent 5.0.0
pigments 0.40.2
python-debugger 0.2.0
python-tools 0.6.9
script 3.18.1
sync-settings 0.8.6
tag 0.5.0
todo-show 2.3.2
I'll have time to take a look next week. In the meantime I'm very happy to take contributions.
This is a problem of the server (pyls-mypy
) not of the consumer. Here's the stdout of pyls
(sudo sysdig -s6000 'proc.cmdline="python -m pyls"' -c stdout
):
Content-Length: 43 Content-Type: application/vscode-jsonrpc; charset=utf8 {"jsonrpc": "2.0", "id": 5, "result": null}:1:1: error: Cannot find module named 'cryptography.hazmat.primitives' :1:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports :2:1: error: Cannot find module named 'cryptography.hazmat.primitives.kdf.hkdf' :3:1: error: Cannot find module named 'cryptography.hazmat.backends.openssl' :4:1: error: Cannot find module named 'cryptography.hazmat.primitives.ciphers' :11:1: error: Cannot find module named 'filetype'
If you look closely some mypy error logging ends up in the process stdout which breaks the protocol.
AFAIU, this happens because mypy API currently works by temporarily overriding sys.stdout
and sys.stde'rr
which is not thread-safe:
def _run(f: Callable[[], None]) -> Tuple[str, str, int]:
old_stdout = sys.stdout
new_stdout = StringIO()
sys.stdout = new_stdout
old_stderr = sys.stderr
new_stderr = StringIO()
sys.stderr = new_stderr
try:
f()
exit_status = 0
except SystemExit as system_exit:
exit_status = system_exit.code
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr
return new_stdout.getvalue(), new_stderr.getvalue(), exit_status
def run(args: List[str]) -> Tuple[str, str, int]:
# Lazy import to avoid needing to import all of mypy to call run_dmypy
from mypy.main import main
return _run(lambda: main(None, args=args))
I'm reporting the bug to pyls-mypy.
I had the same problem. However, setting Python Executable
from python
to python3
resolved the issue for me.
It doesn't happen if I move the ~/.config/pycodestyle
to the project root.
@hoelzlmanuel Could you please elaborate more on your comment? As it seems to be a good way of fixing this issue. Are you creating an alias in the shell?
[Enter steps to reproduce:]
Atom: 1.26.1 x64 Electron: 1.7.11 OS: Mac OS X 10.13.4 Thrown From: ide-python package 0.9.2
Stack Trace
Uncaught Error: Header must provide a Content-Length property.
Commands
Non-Core Packages