sublimelsp / LSP-intelephense

PHP support for Sublime's LSP plugin provided through intelephense.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LSP-intelephense did not respond to the initialize

andremacola opened this issue · comments

How to solve this problem?

I have installed LSP and LSP-intelephense.

I am using NVM to manage node. Do I need to install node without NVM?

LSP-intelephense: Installing server.
Exception in thread Thread-3:
Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "/Users/andremacola/Library/Application Support/Sublime Text 3/Packages/lsp_utils/st3/lsp_utils/server_npm_resource.py", line 21, in run_in_thread
    subprocess.check_call(popen_args, shell=sublime.platform() == 'windows')
  File "./python3.3/subprocess.py", line 542, in check_call
  File "./python3.3/subprocess.py", line 523, in call
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'npm'
lsp-intelephense for /Users/andremacola/Work/Onyx/Paper did not initialize properly. Disabling until this window is restarted
Traceback (most recent call last):
  File "/Users/andremacola/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 335, in get_session
    return self._find_session(config_name, file_path)
  File "/Users/andremacola/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 345, in _find_session
    if session.handles_path(file_path):
  File "/Users/andremacola/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/core/sessions.py", line 208, in handles_path
    with self.acquire_timeout():
  File "./python3.3/contextlib.py", line 48, in __enter__
  File "/Users/andremacola/Library/Application Support/Sublime Text 3/Installed Packages/LSP.sublime-package/plugin/core/sessions.py", line 201, in acquire_timeout
    raise InitializeError(self)
LSP.plugin.core.sessions.InitializeError: lsp-intelephense did not respond to the initialize request within 3 seconds

Fixed this issue including the command inside LSP Settings:

"phpls":
{
   "enabled": false
},
"intelephense-ls":
{
   "command": [
      "/Users/andremacola/.nvm/versions/node/v12.16.1/bin/intelephense",
      "--stdio"
   ],
   "enabled": false
}

That looks like you are going to manage intelephense dependencies by yourself btw.

Yes, the benefit of using this package is that you don't have to install dependency yourself and you get good default settings.

You want to make ST see Node on the PATH so you need to have the nvm initialization code snippet in .profile or .zprofile depending if you use bash or zsh. Refer to nvm documentation also regarding the snippet.

Perhaps it's good to have more explicit instructions in the readme. It's not clear to new users that this plugin requires node to be in the $PATH.

def is_node_installed():
return shutil.which("node") is not None

One way to solve this problem is creating a symlink for node and npm from nvm into your path.

It's a sub-optimal way as the point of nvm is to be able to switch node versions easily. And it's likely that you'll update your node to later version at some point. And then you'll have outdated or non-working symlinks.

The ideal solution is as I've outlined in my previous comment.

@rchl you're right. Symlink is just a quick/temp fix that I did