Open
Description
Check for existing issues
- Completed
Describe the bug / provide steps to reproduce it
I'm implementing a language server command builder.
use zed_extension_api::{self as zed, LanguageServerId, Result};
struct MyExtension {}
impl zed::Extension for MyExtension {
fn new() -> Self {
Self {}
}
fn language_server_command(
&mut self,
language_server_id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
Ok(zed::Command {
command: String::from("java"),
args: vec![
String::from("-cp"),
String::from("C:/Users/enaium/my-language/server.jar"),
String::from("cn.enaium.MainKt"),
],
env: vec![(String::from(""), String::from(""))],
})
}
}
zed::register_extension!(MyExtension);
But Zed will use the work\my-extension
as a Java path.
Environment
Windows 11
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-12-11T15:00:29.8650324+08:00 [INFO] starting language server process. binary path: "C:\\Users\\enaium\\AppData\\Local\\Zed\\extensions\\work\\my-extension\\java"
2024-12-11T15:00:29.8659378+08:00 [ERROR] Failed to start language server "my-language": failed to spawn command. path: "C:\\Users\\enaium\\AppData\\Local\\Zed\\extensions\\work\\my-extension\\java",
2024-12-11T15:00:29.8660027+08:00 [ERROR] server stderr: ""
Activity
RemcoSmitsDev commentedon Dec 11, 2024
I believe there is a method called which on
worktree
variable that you can use to find the binary path ofjava
.Enaium commentedon Dec 12, 2024
command: worktree.which("java").unwrap()
command: format!("'{}'", worktree.which("java").unwrap())
My Java path has space and it still uses the
work\my-extension
path when I wrapper the Java path.2024-12-12T09:11:15.879259+08:00 [ERROR] Failed to start language server "my-language": failed to spawn command. path: "C:\\Users\\enaium\\AppData\\Local\\Zed\\extensions\\work\\my-extension\\\'C:\\Program Files\\BellSoft\\LibericaJDK-21-Full\\bin\\java.exe\'",
Enaium commentedon Dec 12, 2024
I tried execute Java command by PowerShell.