sublimelsp / LSP-json

Schema validation/completions for your JSON and Sublime files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LSP-json cannot seem to find npm

dasayan05 opened this issue · comments

System Info:

  1. Ubuntu 18.04
  2. Sublime Build 4107
  3. node and npm installed at user level (don't have root permission) and visible in ${PATH}

Just after installation, LSP-json showed an error pop-up

Screenshot from 2021-06-07 13-49-36

.. and it is not working. I tried reinstalling and restarting, nothing worked. The sublime's console log shows this:

reloading python 3.3 plugin PackageDev._logging
reloading python 3.3 plugin PackageDev.main
reloading python 3.3 plugin Terminus.main
plugins loaded
Failed to register plugin ""
Traceback (most recent call last):
  File "/user/HS229/ad01424/.config/sublime-text-3/Installed Packages/LSP.sublime-package/plugin/core/sessions.py", line 661, in _register_plugin_impl
    if client_configs.add_external_config(name, settings, base_file, notify_listener):
  File "/user/HS229/ad01424/.config/sublime-text-3/Installed Packages/LSP.sublime-package/plugin/core/settings.py", line 37, in add_external_config
    config = ClientConfig.from_sublime_settings(name, s, file)
  File "/user/HS229/ad01424/.config/sublime-text-3/Installed Packages/LSP.sublime-package/plugin/core/types.py", line 560, in from_sublime_settings
    base = sublime.decode_value(sublime.load_resource(file))
  File "/user/HS229/ad01424/sublime_text/Lib/python33/sublime.py", line 435, in load_resource
    raise IOError('resource "%s" not found' % name)
OSError: resource "Packages//.sublime-settings" not found

Package Control: Skipping automatic upgrade, last run at 2021-06-07 12:50:47, next run at 2021-06-07 13:50:47 or after
Unable to open /user/HS229/ad01424/.config/sublime-text-3/Packages/LSP/LSP.sublime-settings
ignored packages updated to: ["LSP-json", "Vintage"]
reloading settings Packages/User/Package Control.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Package Control.sublime-settings
ignored packages updated to: ["Vintage"]
reloading python 3.3 plugin LSP-json.plugin
reloading settings Packages/User/Package Control.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
Unable to start subprocess for LSP-json
Traceback (most recent call last):
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/server_npm_resource.py", line 88, in install_or_update
    self._node_runtime.npm_install(self._server_dest)
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/node_runtime.py", line 125, in npm_install
    stdout, error = run_command_sync(args, cwd=package_dir)
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/helpers.py", line 20, in run_command_sync
    output = subprocess.check_output(args, cwd=cwd, shell=sublime.platform() == 'windows', stderr=subprocess.STDOUT)
  File "./python3.3/subprocess.py", line 576, in check_output
  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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user/HS229/ad01424/.config/sublime-text-3/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 310, in start_async
    plugin_class.install_or_update()
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/_client_handler/abstract_plugin.py", line 108, in install_or_update
    server.install_or_update()
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/server_npm_resource.py", line 91, in install_or_update
    raise Exception(error)
Exception: [Errno 2] No such file or directory: 'npm'

Unable to start subprocess for LSP-json
Traceback (most recent call last):
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/server_npm_resource.py", line 88, in install_or_update
    self._node_runtime.npm_install(self._server_dest)
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/node_runtime.py", line 125, in npm_install
    stdout, error = run_command_sync(args, cwd=package_dir)
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/helpers.py", line 20, in run_command_sync
    output = subprocess.check_output(args, cwd=cwd, shell=sublime.platform() == 'windows', stderr=subprocess.STDOUT)
  File "./python3.3/subprocess.py", line 576, in check_output
  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'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user/HS229/ad01424/.config/sublime-text-3/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 310, in start_async
    plugin_class.install_or_update()
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/_client_handler/abstract_plugin.py", line 108, in install_or_update
    server.install_or_update()
  File "/user/HS229/ad01424/.config/sublime-text-3/Packages/lsp_utils/st3/lsp_utils/server_npm_resource.py", line 91, in install_or_update
    raise Exception(error)
Exception: [Errno 2] No such file or directory: 'npm'

Kindly help. I an new to sublime and its packages.

You need to have npm installed. Typically this is installed automatically together with node but it seems like not in your case for some reason.

I think in your case the sudo apt install npm would install it.

On my side I guess I should check for npm and offer local node installation if it's missing.

@rchl My system (do not have root access) indeed do not have npm. So I installed afresh a node+npm locally and prioritized in $PATH. I thought LSP-json can pick it up from $PATH but it seems to be not the case. Is there a quick hack by which I can point to my local npm binary?

@rchl I figured it out. It wasn't particularly an LSP-json issue.
It was more related to the fact that launching sublime from Ubuntu GUI launcher cannot capture the $PATH properly as discussed here. That's why LSP-json couldn't figure out the custom npm path. I customized my .desktop launcher file to include the npm path in $PATH .. and it works normally.

I'm making a change anyway so that we check for existance of npm also. If not found then we'll fall back to local Node installation (or ask to install it at least).

sublimelsp/lsp_utils#62