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

[Windows] Failed to start language server, generated path seems invalid #17571

Open
1 task done
conorvenus opened this issue Sep 8, 2024 · 15 comments
Open
1 task done
Labels
bug [core label] language server An umbrella label for all language servers windows

Comments

@conorvenus
Copy link

conorvenus commented Sep 8, 2024

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Whenever Zed attempts to start a language server, it seems to produce the wrong path to the server.js module:

2024-09-08T19:27:04.1166287+01:00 [INFO] starting language server. binary path: "C:\\Users\\conor\\AppData\\Local\\Zed\\node\\node-v22.5.1-win-x64\\node.exe", working directory: "C:\\Users\\conor\\Desktop\\portfolio", args: ["/C:\\Users\\conor\\AppData\\Local\\Zed\\extensions\\work\\svelte/node_modules/svelte-language-server/bin/server.js", "--stdio"]
2024-09-08T19:27:04.1794046+01:00 [ERROR] cannot read LSP message headers
2024-09-08T19:27:04.1796993+01:00 [ERROR] failed to start language server "svelte-language-server": oneshot canceled
2024-09-08T19:27:04.1797999+01:00 [ERROR] server stderr: Some("node:internal/modules/cjs/loader:1222\r\n  throw err;\r\n  ^\r\n\r\nError: Cannot find module 'C:\\C:\\...

It can first be noticed in the args: ["/C:\\..."] with a prepended / which then node seems to interpret as the module being located at C:\\C:\\...

In terms of reproducibility, I am unsure, I just built Zed on my machine, ran it and installed a few extensions and that was it.

Environment

Zed: v0.152.0 (Zed Dev 072513f)
OS: Windows 10.0.22631
Memory: 15.8 GiB
Architecture: x86_64
GPU: Intel(R) Iris(R) Xe Graphics || Intel Corporation || 101.5989

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log
2024-09-08T19:27:04.1166287+01:00 [INFO] starting language server. binary path: "C:\\Users\\conor\\AppData\\Local\\Zed\\node\\node-v22.5.1-win-x64\\node.exe", working directory: "C:\\Users\\conor\\Desktop\\portfolio", args: ["/C:\\Users\\conor\\AppData\\Local\\Zed\\extensions\\work\\svelte/node_modules/svelte-language-server/bin/server.js", "--stdio"]
2024-09-08T19:27:04.1794046+01:00 [ERROR] cannot read LSP message headers
2024-09-08T19:27:04.1796993+01:00 [ERROR] failed to start language server "svelte-language-server": oneshot canceled
2024-09-08T19:27:04.1797999+01:00 [ERROR] server stderr: Some("node:internal/modules/cjs/loader:1222\r\n  throw err;\r\n  ^\r\n\r\nError: Cannot find module 'C:\\C:\\Users\\conor\\AppData\\Local\\Zed\\extensions\\work\\svelte\\node_modules\\svelte-language-server\\bin\\server.js'\r\n    at Module._resolveFilename (node:internal/modules/cjs/loader:1219:15)\r\n    at Module._load (node:internal/modules/cjs/loader:1045:27)\r\n    at TracingChannel.traceSync (node:diagnostics_channel:315:14)\r\n    at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)\r\n    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)\r\n    at node:internal/main/run_main_module:30:49 {\r\n  code: 'MODULE_NOT_FOUND',\r\n  requireStack: []\r\n}\r\n\r\nNode.js v22.5.1\r\n")
@conorvenus conorvenus added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Sep 8, 2024
@AlbertMarashi
Copy link
Contributor

Seems like a windows bug

@SomeoneToIgnore SomeoneToIgnore changed the title Failed to start language server, generated path seems invalid [Windows] Failed to start language server, generated path seems invalid Sep 9, 2024
@dovakin0007
Copy link
Contributor

dovakin0007 commented Sep 9, 2024

its svelte language server specific issue I believe and the same happens with tailwindcss for me but for the other languages it does work fine

@conorvenus
Copy link
Author

its svelte language server specific issue I believe and the same happens with tailwindcss for me but for the other languages it does work fine

I am unsure, because it does the same for HTML too for me - so I am thinking it must just be an issue with how the paths are formed on Windows within Zed for whatever reason.

@dovakin0007
Copy link
Contributor

its svelte language server specific issue I believe and the same happens with tailwindcss for me but for the other languages it does work fine

I am unsure, because it does the same for HTML too for me - so I am thinking it must just be an issue with how the paths are formed on Windows within Zed for whatever reason.

maybe but it has something to do with node modules how they handle directory I didn't have any issues with Zig extension

@conorvenus
Copy link
Author

conorvenus commented Sep 9, 2024

its svelte language server specific issue I believe and the same happens with tailwindcss for me but for the other languages it does work fine

I am unsure, because it does the same for HTML too for me - so I am thinking it must just be an issue with how the paths are formed on Windows within Zed for whatever reason.

maybe but it has something to do with node modules how they handle directory I didn't have any issues with Zig extension

Perhaps - by the looks of it to me, it seems to be a problem within Zed itself passing args as ['/C:\\...'], that prepended / shouldn't be there on Windows (and this is potentially the source of the issue)

@conorvenus
Copy link
Author

conorvenus commented Sep 10, 2024

Ok yeah, as I suspected, the prepended / seems to be the source of the issue:

            Ok(LanguageServerBinary {
                path,
                arguments: command.args.into_iter().map(|arg| arg.replace("/C:", "C:").into()).collect(),
                env: Some(command.env.into_iter().collect()),
            })

Here is a very rudimentary fix for my machine in extension_lsp_adapter.rs, if somebody else who is more familiar with the Zed codebase could figure out where this / on path names is coming from, please let me know.

@JosephTLyons JosephTLyons added language server An umbrella label for all language servers and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Sep 10, 2024
@bartaldavid
Copy link

Any updates on this?
Other than this, the nightly build from https://github.com/deevus/zed-windows-builds seems to work fine.

@ItaloCunhaBueno
Copy link

ItaloCunhaBueno commented Sep 27, 2024

I'm having the exact same issue with svelte's language server, seems to be a node issue, python's language server are working fine. I'm also using deevus nightly build from https://github.com/deevus/zed-windows-builds

Here's the log:

Language server error: svelte-language-server

oneshot canceled
-- stderr--
node:internal/modules/cjs/loader:1251
  throw err;
  ^

Error: Cannot find module 'C:\C:\Users\Italo\AppData\Local\Zed\extensions\work\svelte\node_modules\svelte-language-server\bin\server.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:166:5)
    at node:internal/main/run_main_module:30:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v22.8.0

@JunkuiZhang
Copy link
Contributor

Extension which is downloaded from extension store could not work for now, see #15004

A temp solution:

diff --git a/crates/extension/src/extension_lsp_adapter.rs b/crates/extension/src/extension_lsp_adapter.rs
index 25179acec..ccc1cbf5e 100644
--- a/crates/extension/src/extension_lsp_adapter.rs
+++ b/crates/extension/src/extension_lsp_adapter.rs
@@ -88,7 +88,17 @@ impl LspAdapter for ExtensionLspAdapter {

             Ok(LanguageServerBinary {
                 path,
-                arguments: command.args.into_iter().map(|arg| arg.into()).collect(),
+                arguments: command
+                    .args
+                    .into_iter()
+                    .map(|arg| {
+                        if let Some(arg) = arg.strip_prefix('/') {
+                            arg.into()
+                        } else {
+                            arg.into()
+                        }
+                    })
+                    .collect(),
                 env: Some(command.env.into_iter().collect()),
             })
         }

@edugzlez
Copy link

edugzlez commented Oct 1, 2024

Extension which is downloaded from extension store could not work for now, see #15004

A temp solution:

diff --git a/crates/extension/src/extension_lsp_adapter.rs b/crates/extension/src/extension_lsp_adapter.rs
index 25179acec..ccc1cbf5e 100644
--- a/crates/extension/src/extension_lsp_adapter.rs
+++ b/crates/extension/src/extension_lsp_adapter.rs
@@ -88,7 +88,17 @@ impl LspAdapter for ExtensionLspAdapter {

             Ok(LanguageServerBinary {
                 path,
-                arguments: command.args.into_iter().map(|arg| arg.into()).collect(),
+                arguments: command
+                    .args
+                    .into_iter()
+                    .map(|arg| {
+                        if let Some(arg) = arg.strip_prefix('/') {
+                            arg.into()
+                        } else {
+                            arg.into()
+                        }
+                    })
+                    .collect(),
                 env: Some(command.env.into_iter().collect()),
             })
         }

The problem exists elsewhere as well. The temporary solution does not work globally.

For astro it loads typescript_tsdk_path with env::current_dir(), but this does not pass by argument in the LanguageServerBinary, so it still gives problems.

self.typescript_tsdk_path = env::current_dir()

There should be a way to fix it without having to patch it. It is strange that the env::current_dir() and subsequent instructions are causing this problem.

@JunkuiZhang
Copy link
Contributor

JunkuiZhang commented Oct 1, 2024

There should be a way to fix it without having to patch it. It is strange that the env::current_dir() and subsequent instructions are causing this problem.

From my understanding, the WASM environment is some kind of sand-box, which has a unix-style file system. As a result, when calling current_dir() within WASM, the returned path will always begin with /. Unfortunately, it seems there's no way to change this behavior.

@alvgaona
Copy link
Contributor

The same happens for @astrojs/language-server in Windows.

Language server error: astro-language-server

oneshot canceled
-- stderr--
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'C:\C:\Users\alvga\AppData\Local\Zed\extensions\work\astro\node_modules\@astrojs\language-server\bin\nodeServer.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.5.0

For some reason it has C:\C:\.

@simonerlic
Copy link

The same happens for @astrojs/language-server in Windows.

Language server error: astro-language-server

oneshot canceled
-- stderr--
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'C:\C:\Users\alvga\AppData\Local\Zed\extensions\work\astro\node_modules\@astrojs\language-server\bin\nodeServer.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.5.0

For some reason it has C:\C:\.

Curious -- do you have multiple drives? I wonder if this is a multi-drive issue on Windows. Mine shows as D:\C:\, as my projects are on D:\

@alvgaona
Copy link
Contributor

The same happens for @astrojs/language-server in Windows.

Language server error: astro-language-server

oneshot canceled
-- stderr--
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'C:\C:\Users\alvga\AppData\Local\Zed\extensions\work\astro\node_modules\@astrojs\language-server\bin\nodeServer.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.5.0

For some reason it has C:\C:\.

Curious -- do you have multiple drives? I wonder if this is a multi-drive issue on Windows. Mine shows as D:\C:\, as my projects are on D:\

My projects are in C:\ . I have an extra drive with letter E:\.

@simonerlic
Copy link

The same happens for @astrojs/language-server in Windows.

Language server error: astro-language-server

oneshot canceled
-- stderr--
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module 'C:\C:\Users\alvga\AppData\Local\Zed\extensions\work\astro\node_modules\@astrojs\language-server\bin\nodeServer.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.5.0

For some reason it has C:\C:\.

Curious -- do you have multiple drives? I wonder if this is a multi-drive issue on Windows. Mine shows as D:\C:\, as my projects are on D:\

My projects are in C:\ . I have an extra drive with letter E:\.

I'm starting to think that this might be caused by the assumption that the user has a single-drive system - maybe whatever call they make to get the file path returns just the path normally on a single drive system, and the path with the drive on multi drive systems?

I'll take a look this evening, as I'm not familiar with how it determines the path currently.

@github-actions github-actions bot added admin read Pending admin review triage Maintainer needs to classify the issue labels Nov 5, 2024
@notpeter notpeter removed the triage Maintainer needs to classify the issue label Nov 5, 2024
@notpeter notpeter removed the admin read Pending admin review label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] language server An umbrella label for all language servers windows
Projects
None yet
Development

No branches or pull requests