Sublime Forum

ST4: LSP fails to install (any) language server

#21

This doesn’t use npm managed by lsp_utils. It uses C:\Users\diakosi7344\AppData\Roaming\npm\node_modules\npm\lib\commands\ci.js

0 Likes

#22

Sorry I notice an typo in my previous post.

What if you change lsp_utils settings to

{
    // Specifies the type and priority of the Node.js installation that should be used for Node.js-based servers.
    // The allowed values are:
    //  - 'system' - a Node.js runtime found on the PATH
    //  - 'local' - a Node.js runtime managed by LSP that doesn't affect the system
    // The order in which the values are specified determines which one is tried first,
    // with the later one being used as a fallback.
    // You can also specify just a single value to disable the fallback.
    "nodejs_runtime": ["local", "system"],
    "local_use_electron": false,
}

This should use lsp_utils-managed one.

0 Likes

#23

As stated in the above posts:

  • I tried this suggestion at first and it worked.
  • After some days, Package Manager got auto-updated.
  • As such the error appeared again.

I am trying to see if something is wrong with my environment variables after having removed nvm.
I also forced deleted anything in the npm cache (and verified) by doing:

  • npm cache clean --force
  • npm cache verify

I will get back to you to see if I have progressed any further. Please bear with me :slight_smile:

0 Likes

#24

In case you didn’t notice, this settings is not what I post, I’ve modified it. So I am not sure whether " * I tried this suggestion at first and it worked." still apply here. At least I still doesn’t see an error log for lsp_utils-managed env.

0 Likes

#25

My apologies.
Where can I find that log then?

In the meantime, I tidied up my environment variables (removed any invalid references to NodeJS and npm), removed the NMV installer (just to be safe), removed NodeJS and ST4 and removed all relevant ST4 and NodeJS / NPM data in Roaming and Local directories.
Rebooted at every step.

I installed everything but now I get this: image

It’s not my day is it? :stuck_out_tongue:

0 Likes

#26

Just like those you post before. But what I am interested in is log for lsp_utils-managed env but not your own.

That is, use settings in ST4: LSP fails to install (any) language server and post error log where you can find in ST console just like before.

Or even more aggressive, just "nodejs_runtime": ["local"], so it probably never uses a system one.

0 Likes

#27

I am sorry but I do not follow.
That is the only log I get from ST4 as stated. Do you want the whole file to be attached?

I did change it now after the whole nuke thing but it is not apparent to me where system is expected to reside and where local is expected to reside. Is there any relevant documentation where this is explained?
I expect system to be in C:/Program Files/nodejs but local in %USERPROFILE%? Previously when I used the local it installed all those LSP NPM packages within the project folder. Maybe that broke it again after Package Control got auto-upgraded? Now it works but I do not understand where local points to. A bit confused in that part.

Sorry for being a pain in the a** but these thing has created all sorts of problems for me :stuck_out_tongue:

0 Likes

#28

“local” installs node.js in C:\Users\jfcherng\AppData\Local\Sublime Text\Package Storage\lsp_utils\node-runtime, where jfcherng is my username.

0 Likes

#29

Also, the popup occurs because I had a package-lock.json file there. This is what caused the crash but I removed it and then got this:

[lsp_utils] START output of command: “ci --omit=dev --scripts-prepend-node-path=true --verbose”

[lsp_utils] Command output END
Unable to start subprocess for LSP-json
Traceback (most recent call last):
File “C:\Users\DIAKOS~1\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\server_npm_resource.py”, line 123, in install_or_update
self._node_runtime.run_install(cwd=self._server_dest)
File “C:\Users\DIAKOS~1\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\node_runtime.py”, line 217, in run_install
raise Exception(‘Failed to run npm command “{}”:\n{}’.format(’ '.join(args), error))
Exception: Failed to run npm command “ci --omit=dev --scripts-prepend-node-path=true --verbose”:
npm verb cli C:\Program Files\nodejs\20_9\node.exe C:\Program Files\nodejs\20_9\node_modules\npm\bin\npm-cli.js
npm info using npm@10.1.0
npm info using node@v20.9.0
npm verb title npm ci
npm verb argv “ci” “–omit” “dev” “–scripts-prepend-node-path” “true” “–loglevel” “verbose”
npm verb logfile logs-max:10 dir:C:\Users\diakosi7344\AppData\Local\npm-cache_logs\2023-10-25T17_18_01_818Z-
npm verb logfile C:\Users\diakosi7344\AppData\Local\npm-cache_logs\2023-10-25T17_18_01_818Z-debug-0.log
npm verb stack Error: ENOENT: no such file or directory, open ‘C:\Users\diakosi7344\package.json’
npm verb cwd C:\Users\diakosi7344
npm verb Windows_NT 10.0.22621
npm verb node v20.9.0
npm verb npm v10.1.0
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\diakosi7344/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open ‘C:\Users\diakosi7344\package.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm verb exit -4058
npm verb code -4058

npm ERR! A complete log of this run can be found in: C:\Users\diakosi7344\AppData\Local\npm-cache_logs\2023-10-25T17_18_01_818Z-debug-0.log

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “C:\Users\diakosi7344\AppData\Roaming\Sublime Text\Installed Packages\LSP.sublime-package\plugin/core/windows.py”, line 250, in start_async
plugin_class.install_or_update()
File “C:\Users\DIAKOS~1\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils_client_handler\abstract_plugin.py”, line 109, in install_or_update
server.install_or_update()
File “C:\Users\DIAKOS~1\AppData\Roaming\SUBLIM~1\Packages\LSP_UT~1\st3\lsp_utils\server_npm_resource.py”, line 127, in install_or_update
raise Exception(‘Error installing the server:\n{}’.format(error))
Exception: Error installing the server:
Failed to run npm command “ci --omit=dev --scripts-prepend-node-path=true --verbose”:
npm verb cli C:\Program Files\nodejs\20_9\node.exe C:\Program Files\nodejs\20_9\node_modules\npm\bin\npm-cli.js
npm info using npm@10.1.0
npm info using node@v20.9.0
npm verb title npm ci
npm verb argv “ci” “–omit” “dev” “–scripts-prepend-node-path” “true” “–loglevel” “verbose”
npm verb logfile logs-max:10 dir:C:\Users\diakosi7344\AppData\Local\npm-cache_logs\2023-10-25T17_18_01_818Z-
npm verb logfile C:\Users\diakosi7344\AppData\Local\npm-cache_logs\2023-10-25T17_18_01_818Z-debug-0.log
npm verb stack Error: ENOENT: no such file or directory, open ‘C:\Users\diakosi7344\package.json’
npm verb cwd C:\Users\diakosi7344
npm verb Windows_NT 10.0.22621
npm verb node v20.9.0
npm verb npm v10.1.0
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\diakosi7344/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open ‘C:\Users\diakosi7344\package.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm verb exit -4058
npm verb code -4058

npm ERR! A complete log of this run can be found in: C:\Users\diakosi7344\AppData\Local\npm-cache_logs\2023-10-25T17_18_01_818Z-debug-0.log

Notice that now it expects a package.json in %USERPROFILE% (aka C:\Users\diakosi7344/)
Then, I tried using local again to see if it would work and thank God it did. However, the whole setup seems flaky with all those errors and popup crashes :smiley: (no offence meant).

All the LSP packages I installed expect it there? However, I don’t see now any node_modules folder or any package-lock.json file or package.json file.

0 Likes

#30

In short:

  • nvm does not play well with ST4
  • environment variables should be tidied up in case of deduplicated vars (so npm in user env PATH and nodejs in SYS env path)
  • package-lock.json file may cause LSP to loop and crash (reproducible)
0 Likes

#31

Ah perfect! That’s very useful! Thanks! :slight_smile:

I can confirm I have a node_runtime in C:\Users\diakosi7344\AppData\Local\Sublime Text\Package Storage\lsp_utils\node-runtime\18.18.1\node and the LSP-* stuff are finally working.

Hopefully, they do not break again! :crossed_fingers:

0 Likes

#32

Uh… so what you did to make it work?

0 Likes

#33
  • I removed nvm NodeJS installations and removed nvm too.
  • Removed NVM env vars and any old vars related to NodeJS.
  • Installed NodeJS and verified env vars are correct (used a Windows Sandbox to verify this).
  • Nuked ST4 and Sublime Merge and all AppData related folders in that dir and reinstalled

I had to reboot between all these steps just to be safe.

0 Likes

#34

That’s… quite a lot. Ideally I would like to see an error log when using

{
    // Specifies the type and priority of the Node.js installation that should be used for Node.js-based servers.
    // The allowed values are:
    //  - 'system' - a Node.js runtime found on the PATH
    //  - 'local' - a Node.js runtime managed by LSP that doesn't affect the system
    // The order in which the values are specified determines which one is tried first,
    // with the later one being used as a fallback.
    // You can also specify just a single value to disable the fallback.
    "nodejs_runtime": ["local"],
    "local_use_electron": false,
}

with whatever your user environment (e.g., with NVM installed).


But I guess you are tired of trying these things so :man_shrugging: whatever works.

0 Likes

#35

The error I got says there are logs in C:\Users\diakosi7344\AppData\Local\npm-cache_logs. Do you want me to go through that folder and look for a … lsp_utils-managed.log file? Can you be more specific please?

0 Likes

#36

I would like to first make sure “local” npm is used rather than the system one.

0 Likes

#37

Ok. So, do you want me to remove the system option in LSP utils and see if it works with local only? Do I understand correctly?

0 Likes

#38

yes, exactly.

0 Likes

#39

I just did and no issue occurs. I opened also a new CSS file after having just installed LSP-css and it installed correctly. Every other tools seems to init again correctly (e.g LSP-json, LSP-typescript etc).

P.S.: By install, I mean when it says installing LSP-xxx… below the sublime editor on the left corner.

0 Likes

#40

It’s okay even if you have NVM on your machine?

0 Likes