-
-
Notifications
You must be signed in to change notification settings - Fork 900
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
ts-ls: Wrong lsp-clients-typescript-server-path #4254
Comments
I'm having this issue as well. Reverting the change from #4202 to line 803 resolved it. |
@kiennq - seems like it is a regression? |
I am having a rather hard time getting lsp to work in a TypeScript project in a subdirectory due to this problem. |
same issue here, and resolved by follow @hamaker's suggestion. I guess that new code didn't include all kind of npm install path. For my case, I'm using nvm, and my global install path is in And I can use didn't really deep into what's going on here, though, hope someone can solve this problem :) |
try to dig deeper into the problem, I think that maybe not related to various of npm install path. Maybe that logic just wrong in linux environment? I thought that PR with the problem try to fix issue on window's version |
Stop reading `node_modules` directly by the file system. The problem with this direct loading is that projects without `node_modules` in the top-level directory will not work at all. For example, when I develop with aws cdk, I cut off the `cdk` or `infra` directory and create a new `package.json` and put `node_modules` there too, but in that case, the code before this modification will not work at all. I solved this problem by simply inserting an abstraction layer. Relation. * [lsp-javascript: supply correct path to tsserver for ts-ls by kiennq · Pull Request emacs-lsp#4202 · emacs-lsp/lsp-mode](emacs-lsp#4202) * [ts-ls: Wrong lsp-clients-typescript-server-path · Issue emacs-lsp#4254 · emacs-lsp/lsp-mode](emacs-lsp#4254)
I'm getting the same problem in (ubuntu) Linux; also: Deleting This, however, does not happen in macOS; all language servers are correctly detected under |
On my machine, my emacs.d cache folder looks like this:
Similar to the issue description, the elisp statement linked there evaluates to The fix in #4284 works for me, and as a quick workaround without having to locally edit my elpa files, adding a node_modules symlink in the path that lsp-mode is erroneously looking in also works:
|
I'm seeing this error on Debian Linux with Emacs 29.2. As a temporary workaround, I've created a symlink via
NB Amend |
My problem was solved by the PR I sent out last month, does this solve yours? |
Can someone give this a test? 🤔 Thanks! |
Thanks @ncaq - your PR seems to fix the problem for me. |
This doesn't look right. If you are on windows, the path looks like: 🤔
|
Can someone test #4389? It should work on both Unix-like and Windows systems. 🤔 |
It looks good to me. |
Completed in #4389. |
I'm referencing the node_modules directory from the lsp root, so the problem isn't solved in environments with node_modules in subdirectories, etc. that my PR solved. should this be a separate issue? |
Perhaps you are under the mistaken impression that my PR is simply to change the PATH specification of the original issue contributor, while my PR is to stop referring to the PATH directly... |
I have checked it works on Windows and found that it certainly does not work on Windows, even with the content of my PR, so I would like to correct it. |
@jcs090218 |
It's better to be in separate issues. 👍 The title is a bit misleading. 🤔 |
* fix: remove direct references to the node_modules directory Stop reading `node_modules` directly by the file system. The problem with this direct loading is that projects without `node_modules` in the top-level directory will not work at all. For example, when I develop with aws cdk, I cut off the `cdk` or `infra` directory and create a new `package.json` and put `node_modules` there too, but in that case, the code before this modification will not work at all. I solved this problem by simply inserting an abstraction layer. Relation. * [lsp-javascript: supply correct path to tsserver for ts-ls by kiennq · Pull Request #4202 · emacs-lsp/lsp-mode](#4202) * [ts-ls: Wrong lsp-clients-typescript-server-path · Issue #4254 · emacs-lsp/lsp-mode](#4254) * fix(lsp-javascript): remove shell redirect when call node In the case of Windows, etc., `shell-command-to-string` is to use a non-bash shell. To begin with, `shell-command-to-string` seems to ignore standard error output. * refactor(lsp-javascript): rename function and add docs `lsp-clients-typescript-server-path-by-node-require` is too long. * fix(lsp-javascript): use Node.js require to explore Pros === Since Node.js require indicates the path where the file actually exists, it automatically adapts to various environments unless there are significant system changes or changes in the usage environment. Cons === There is a small overhead at first startup due to the command execution. * refactor: use `if-let*` and `when-let*` Simplified based on code review.
…p#4333) * fix: remove direct references to the node_modules directory Stop reading `node_modules` directly by the file system. The problem with this direct loading is that projects without `node_modules` in the top-level directory will not work at all. For example, when I develop with aws cdk, I cut off the `cdk` or `infra` directory and create a new `package.json` and put `node_modules` there too, but in that case, the code before this modification will not work at all. I solved this problem by simply inserting an abstraction layer. Relation. * [lsp-javascript: supply correct path to tsserver for ts-ls by kiennq · Pull Request emacs-lsp#4202 · emacs-lsp/lsp-mode](emacs-lsp#4202) * [ts-ls: Wrong lsp-clients-typescript-server-path · Issue emacs-lsp#4254 · emacs-lsp/lsp-mode](emacs-lsp#4254) * fix(lsp-javascript): remove shell redirect when call node In the case of Windows, etc., `shell-command-to-string` is to use a non-bash shell. To begin with, `shell-command-to-string` seems to ignore standard error output. * refactor(lsp-javascript): rename function and add docs `lsp-clients-typescript-server-path-by-node-require` is too long. * fix(lsp-javascript): use Node.js require to explore Pros === Since Node.js require indicates the path where the file actually exists, it automatically adapts to various environments unless there are significant system changes or changes in the usage environment. Cons === There is a small overhead at first startup due to the command execution. * refactor: use `if-let*` and `when-let*` Simplified based on code review.
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
#4202 made some changes to handle a deprecated argument in the language server. This included changing
lsp-clients-typescript-server-path()
to return:lsp-mode/clients/lsp-javascript.el
Line 803 in 01bd566
For me this evaluates to
~/.emacs.d/var/lsp/server/npm/typescript/bin/node_modules/typescript/lib
, whiletsserver.js
is actually in~/.emacs.d/var/lsp/server/npm/typescript/lib/node_modules/typescript/lib
. So I guess the line above should be:Steps to reproduce
.js
file withts-ls
, the following error appears:LSP :: Error from the Language Server: Request initialize failed with message: Could not find a valid TypeScript installation. Please ensure that the "typescript" dependency is installed in the workspace or that a valid
tsserver.pathis specified. Exiting. (Internal Error)
Expected behavior
ts-ls
starts normallyWhich Language Server did you use?
lsp-javascript/ts-ls
OS
Linux
Error callstack
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: