python-lsp / python-lsp-server

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

Failed to load hook pylsp_lint: No such file or directory: flake8_lint.py in run_flake8 #428

Closed Magicrafter13 closed 10 months ago

Magicrafter13 commented 10 months ago

At first I thought this was #369 until I realized it's in a different file (plus I tried manually applying the fix that was made for it, and it didn't resolve the issue).

I'm trying to get pylsp working with nvim-lspconfig in neovim. If I just use default settings, something seems to work, but as soon as I try configuring pylsp, I get errors like this:

Traceback (most recent call last):
  File \"/usr/lib/python3.11/site-packages/pylsp/plugins/flake8_lint.py\", line 108, in run_flake8
    p = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE, cwd=document._workspace.root_path)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/subprocess.py\", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File \"/usr/lib/python3.11/subprocess.py\", line 1917, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/usr/lib/python3.11/site-packages/pylsp/config/config.py\", line 33, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/site-packages/pluggy/_manager.py\", line 418, in traced_hookexec
    return outcome.get_result()
           ^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/site-packages/pluggy/_result.py\", line 108, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File \"/usr/lib/python3.11/site-packages/pluggy/_result.py\", line 70, in from_call
    result = func()
             ^^^^^^
  File \"/usr/lib/python3.11/site-packages/pluggy/_manager.py\", line 415, in <lambda>
    lambda: oldcall(hook_name, hook_impls, caller_kwargs, firstresult)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/site-packages/pluggy/_callers.py\", line 116, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File \"/usr/lib/python3.11/site-packages/pluggy/_callers.py\", line 80, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/site-packages/pylsp/plugins/flake8_lint.py\", line 83, in pylsp_lint
    output = run_flake8(flake8_executable, args, document)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/site-packages/pylsp/plugins/flake8_lint.py\", line 113, in run_flake8
    p = Popen(  # pylint: disable=consider-using-with
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/subprocess.py\", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File \"/usr/lib/python3.11/subprocess.py\", line 1917, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ''

Here's the config I'm using in NeoVim:

-- Setup language servers.
local lspconfig = require('lspconfig')
lspconfig.pylsp.setup {
    settings = {
        pylsp = {
            plugins = {
                autopep8 = {
                    enabled = true
                },
                flake8 = {
                    enabled = true
                },
                pylint = {
                    enabled = true,
                    executable = "/usr/bin/pylint"
                }
            }
        }
    }
}
ccordoba12 commented 10 months ago

Hey @Magicrafter13, thanks for reporting. I think this is a duplicate of issue #406, so I'm going to close it as such.

We'll try to fix in our next version (1.8.0).

Magicrafter13 commented 10 months ago

My bad