Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs more documentation for end-users on where to define node_bin #53

Open
rwols opened this issue Feb 25, 2021 · 10 comments
Open

Needs more documentation for end-users on where to define node_bin #53

rwols opened this issue Feb 25, 2021 · 10 comments

Comments

@rwols
Copy link
Member

rwols commented Feb 25, 2021

A lot of npm-based packages have a ${node_bin} variable now but it's not clear to me how to customize that.

@rchl
Copy link
Member

rchl commented Feb 25, 2021

People don't explicitly install lsp_utils but just get it by proxy. So I'm not sure what would be a good place to educate the user.

Technically the user doesn't really need to customize it. Initially I wasn't even planning on having a setting for it. Only that it serves the purpose of helping the user if his PATH is not setup properly.

@rchl
Copy link
Member

rchl commented Mar 8, 2021

I suppose the solution to this is to just add a comment line like https://github.com/sublimelsp/LSP-json/blob/c99d736ff165e734e32ca7a07e0aac2b58c66cbd/LSP-json.sublime-settings#L2 to all packages that use "node_bin".

@andy0130tw
Copy link

I thought the Node.js path finding mechanism was a little bit obscured, especially when you were not using the system-provided Node binary or npm script. I gave up at the end and read the source code to figure out what happened. Ended up adding my own hack in the node_runtime.py: https://gist.github.com/andy0130tw/8377e7f7f4e36d1c231001271e166e24

@rchl
Copy link
Member

rchl commented Nov 15, 2023

Looks like you don't want to use Node from the PATH then and instead manually hardcode the path to Node in the command option in the helper package.

@rchl
Copy link
Member

rchl commented Nov 15, 2023

Actually I'm not sure how would that work in your case.

Also not sure what sort of solution would you see for that case. Everything really relies on node being in the PATH if you are not using bundled Node.

@andy0130tw
Copy link

Sorry for lack of clarity. Considering that Sublime Text is a GUI application, I think it is common for users within a desktop environment to launch it from their desktop e.g., application menu, instead of from the terminal. The way of configuring a PATH variable for an application is DE-dependent and generally not straightforward. The complexity is compounded in the case of lsp_utils because it also requires a working npm.

On the other hand, opting for a bundled Node "just works", but it means that a Node environment is duplicated, extra installation time involves, and one need to store all those language-server dependencies in some cache directory. In my assessment on average use cases, that should be considered the last resort.

As a result, I prefer that there is yet another way to specify the path to node/npm, even if it requires hardcoding them in the config.

@rchl
Copy link
Member

rchl commented Nov 15, 2023

If you intention is to use a single local node instance within whole of ST then you should be able to do that by exposing it in PATH. Here is how it should be configured on a system-basis - https://lsp.sublimetext.io/troubleshooting/#updating-the-path-used-by-lsp-servers

If you want to use different node instance per project then that's not really compatible with PATH approach as that is global for the whole application.

So is your intention to be able to configure node instance per-project?

@andy0130tw
Copy link

andy0130tw commented Nov 15, 2023

When you add it to the .profile, it also affects any other programs that are launched from your login session. I avoid doing that. And then I tried out the env: ... parameter method described in the docs for LSP-typescript. Despite of the fact that it showed up in the troubleshooting page, it seemed that the language server did not use the updated PATH.

// Settings in here override those in "LSP-typescript/LSP-typescript.sublime-settings"

{
    "initializationOptions": {
        "disableAutomaticTypingAcquisition": true,
        "locale": "zh-TW",
    },
    "enabled": true,
    "env": {
        "PATH": "/Users/qbane/.volta/bin:$PATH"
    }
}

@rchl
Copy link
Member

rchl commented Nov 15, 2023

env only applies for the started language server process. It doesn't affect pre-start of the server.

But my question was (out of curiosity, not promising anything) what would be a satisfactory solution for you.

  • a global LSP settings to set a node path and use it for all servers?
  • specify separate node path per-server?

@andy0130tw
Copy link

Well... I think a global setting is sufficient for me. Different type of language servers or projects may depend on different version of packages, but they can check and apply their own config after starting up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants