Skip to content

Conversation

@valentinegb
Copy link
Collaborator

@valentinegb valentinegb commented Dec 6, 2024

This PR rewrites the code for downloading JDTLS, the language server. Now, it fetches GitHub tags to determine the latest version. Since the extension is now capable of determining the best version to download, the jdtls_version setting has been removed.

@valentinegb valentinegb added enhancement New feature or request language-server Related to the language server. labels Dec 6, 2024
@cla-bot cla-bot bot added the cla-signed label Dec 6, 2024
@valentinegb
Copy link
Collaborator Author

On my machine, there's something very wrong with std::fs::remove_dir_all in all extensions that use it. Does anyone else get stuck on "Downloading jdtls..." if the extension has installed an older version before or just me? (You can test it by renaming the latest version directory in ~/Library/Application Support/Zed/extensions/work/java/ to something else.)

@notpeter
Copy link
Contributor

I removed my copy of jdtls and installed from this branch it downloaded as expected.

I am not able to reproduce the issue you were having with it getting stuck "Downloading jdtls...". I renamed mv jdt-language-server-1.42.0-202411281516 jdt-language-server-1.41.0-fake in that directory and relaunched Zed and it seemed to redownload without issue. But it also didn't cleanup the old directory either. Let me know if I misunderstood your steps to reproduce.

@valentinegb
Copy link
Collaborator Author

Interesting... 1) could you check if any of the contents of the renamed directory were removed and 2) I just added some extra debugging, could you try testing again and send Zed's logs?

@notpeter
Copy link
Contributor

notpeter commented Dec 12, 2024

Yeah, so I pulled, rebuilt and restarted zed and got this:

Zed.log 1 ``` 2024-12-12T17:26:47.954401-05:00 [INFO] attempting to start language server "jdtls", path: "/Users/peter/zcode/zed", id: 2 2024-12-12T17:26:47.95457-05:00 [INFO] Initializing default prettier with plugins {"prettier-plugin-java"} 2024-12-12T17:26:48.411644-05:00 [INFO] Installing default prettier and plugins: [("prettier-plugin-java", "2.6.5"), ("prettier", "3.4.2")] 2024-12-12T17:26:48.440034-05:00 [INFO] starting language server process. binary path: "/Users/peter/Library/Application Support/Zed/extensions/work/java/jdt-language-server-1.42.0-202411281516/bin/jdtls", working directory: "/Users/peter/zcode/zed", args: [] 2024-12-12T17:26:48.929457-05:00 [INFO] Initialized prettier with plugins: {"prettier-plugin-java"} 2024-12-12T17:26:50.077777-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Starting", "message": "Init..." } 2024-12-12T17:26:50.078011-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Starting", "message": "0% Starting Java Language Server" } 2024-12-12T17:26:51.740372-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Starting", "message": "21% Starting Java Language Server" } 2024-12-12T17:26:52.140695-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Starting", "message": "22% Starting Java Language Server" } 2024-12-12T17:26:52.140964-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "ProjectStatus", "message": "OK" } 2024-12-12T17:26:52.141112-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Starting", "message": "100% Starting Java Language Server" } 2024-12-12T17:26:52.141662-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Started", "message": "Ready" } 2024-12-12T17:26:52.142599-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "Starting", "message": "100% Starting Java Language Server" } 2024-12-12T17:26:52.151502-05:00 [WARN] unhandled capability registration: Registration { id: "30d57210-b34d-4eb8-b060-2bbfdeba65c7", method: "workspace/didChangeWorkspaceFolders", register_options: None } 2024-12-12T17:26:52.151723-05:00 [INFO] Language server with id 2 sent unhandled notification language/status: { "type": "ServiceReady", "message": "ServiceReady" } 2024-12-12T17:26:54.753469-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:26:55.852017-05:00 [INFO] Language server with id 2 sent unhandled notification language/eventNotification: { "eventType": 100, "data": "file:/Users/peter/zcode/zed/" } 2024-12-12T17:26:55.852391-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:26:57.564708-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:26:59.078649-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:00.585048-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:02.094191-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:03.603364-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:05.112192-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:06.621215-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:08.182152-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:09.692932-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:11.202581-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:12.713571-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:14.224109-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" 2024-12-12T17:27:15.735385-05:00 [WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8" ```

Are you seeing lines like this in your logs?

[WARN] skipping diagnostics update, no worktree found for path "/private/var/folders/86/wdxpwlqx2c31t7xpvwpt6zt40000gn/T/jdtls-5821b64a451562259b97b81a520ee86732b78a62/zed_67676eb8"

When I go into that directory it appears to be an duplicated copy of the worktree that contained the empty file (a.java) I opened. This happened to be zed-industries/zed which is ~5.5GB + another 5GB of junk under /target -- allow which appears to be copied into my $TMPDIR.

It may be par for the course that jdtls duplicates the directory containing your file in an attempt to build out of tree, but it is not what I expected.


I reloaded Zed and saw this:
Screenshot 2024-12-12 at 17 36 42

It was trying to copy my shit (slowly) but instead of waiting many minutes I quit zed.
And ran:

cd "$HOME/Library/Application Support/Zed/extensions/work/java"
rm -rf jdt-language-server-1.42.0-202411281516

When I restarted Zed this ended up in my Zed logs (looks like your remove_dir_all_recursive)

Zed.log 2
2024-12-12T17:39:55.359866-05:00 [INFO] Initializing default prettier with plugins {"prettier-plugin-java"}
2024-12-12T17:39:55.364716-05:00 [INFO] Installing default prettier and plugins: [("prettier-plugin-java", "2.6.5"), ("prettier", "3.4.2")]
2024-12-12T17:39:55.5466-05:00 [INFO] starting language server process. binary path: "/opt/homebrew/opt/node@20/bin/node", working directory: "/Users/peter/zcode/zed", args: ["/Users/peter/Library/Application Support/Zed/languages/json-language-server/node_modules/vscode-langservers-extracted/bin/vscode-json-language-server", "--stdio"]
2024-12-12T17:39:55.895111-05:00 [INFO] Initialized prettier with plugins: {"prettier-plugin-java"}
2024-12-12T17:39:56.205991-05:00 [INFO] attempting to start language server "jdtls", path: "/Users/peter/zcode/zed", id: 2
2024-12-12T17:39:59.387781-05:00 [ERROR] Failed to start language server "jdtls": error while executing at wasm backtrace:
    0: 0x28318 - java.wasm!__rust_start_panic
    1: 0x2777a - java.wasm!rust_panic
    2: 0x276b6 - java.wasm!std::panicking::rust_panic_with_hook::h002a9d757cec9266
    3: 0x268e5 - java.wasm!std::panicking::begin_panic_handler::{{closure}}::h5e11e16f0cbe0dd6
    4: 0x26856 - java.wasm!std::sys::backtrace::__rust_end_short_backtrace::h34d7c06dcd4fe40d
    5: 0x27006 - java.wasm!rust_begin_unwind
    6: 0x2de59 - java.wasm!core::panicking::panic_fmt::h7e49d43cccf0228e
    7: 0x2dfc7 - java.wasm!core::slice::index::slice_end_index_len_fail::hd4374c81ba7a2894
    8: 0x248c1 - java.wasm!<std::sys::pal::wasi::fs::ReadDir as core::iter::traits::iterator::Iterator>::next::he4d4ac3f8ccdea64
    9: 0x27f64 - java.wasm!std::sys::pal::wasi::fs::remove_dir_all_recursive::hfeb30a9063e65819
   10: 0x27eae - java.wasm!std::sys::pal::wasi::fs::remove_dir_all_recursive::hfeb30a9063e65819
   11: 0x27eae - java.wasm!std::sys::pal::wasi::fs::remove_dir_all_recursive::hfeb30a9063e65819
   12: 0x27bfb - java.wasm!std::sys::pal::wasi::fs::remove_dir_all::hd252435211c84e77
   13: 0x97f0 - java.wasm!std::fs::remove_dir_all::hdb65a5d95186e9e6
   14: 0x604c - java.wasm!<java::Java as zed_extension_api::Extension>::language_server_command::hae46f32feea16fa8
   15: 0xd06c - java.wasm!zed_extension_api::wit::_export_language_server_command_cabi::h341b426423219b05
   16: 0x18a2d - java.wasm!language-server-command
   17: 0x38574 - java.wasm!language-server-command.command_export
2024-12-12T17:39:59.389177-05:00 [ERROR] server stderr: ""

So I decided to see if this would happen with a clean slate.
I quit Zed and ran:

cd "$HOME/Library/Application Support/Zed/extensions/work/java"
mv jdt-language-server-1.42.0-{202411281516,fake3}

cd $(readlink -f $TMPDIR)/
ls -dl  jdtls-*
# three directories, the one referenced above (zed; 10GB), one from when earlier this morning (zed-brainfuck; 44MB) and one from November 21 (empty).

rm -rf jdtls-*
# slow; takes a while to delete 10GB of stuff.

mkdir -p /tmp/java1/
touch /tmp/java1/foo.java
zedn /tmp/java1/ /tmp/java1/foo.java

Same panic:

Zed.log Panic
2024-12-12T17:55:15.312213-05:00 [ERROR] Failed to start language server "jdtls": error while executing at wasm backtrace:
    0: 0x28318 - java.wasm!__rust_start_panic
    1: 0x2777a - java.wasm!rust_panic
    2: 0x276b6 - java.wasm!std::panicking::rust_panic_with_hook::h002a9d757cec9266
    3: 0x268e5 - java.wasm!std::panicking::begin_panic_handler::{{closure}}::h5e11e16f0cbe0dd6
    4: 0x26856 - java.wasm!std::sys::backtrace::__rust_end_short_backtrace::h34d7c06dcd4fe40d
    5: 0x27006 - java.wasm!rust_begin_unwind
    6: 0x2de59 - java.wasm!core::panicking::panic_fmt::h7e49d43cccf0228e
    7: 0x2dfc7 - java.wasm!core::slice::index::slice_end_index_len_fail::hd4374c81ba7a2894
    8: 0x248c1 - java.wasm!<std::sys::pal::wasi::fs::ReadDir as core::iter::traits::iterator::Iterator>::next::he4d4ac3f8ccdea64
    9: 0x27f64 - java.wasm!std::sys::pal::wasi::fs::remove_dir_all_recursive::hfeb30a9063e65819
   10: 0x27eae - java.wasm!std::sys::pal::wasi::fs::remove_dir_all_recursive::hfeb30a9063e65819
   11: 0x27eae - java.wasm!std::sys::pal::wasi::fs::remove_dir_all_recursive::hfeb30a9063e65819
   12: 0x27bfb - java.wasm!std::sys::pal::wasi::fs::remove_dir_all::hd252435211c84e77
   13: 0x97f0 - java.wasm!std::fs::remove_dir_all::hdb65a5d95186e9e6
   14: 0x604c - java.wasm!<java::Java as zed_extension_api::Extension>::language_server_command::hae46f32feea16fa8
   15: 0xd06c - java.wasm!zed_extension_api::wit::_export_language_server_command_cabi::h341b426423219b05
   16: 0x18a2d - java.wasm!language-server-command
   17: 0x38574 - java.wasm!language-server-command.command_export
2024-12-12T17:55:15.314752-05:00 [ERROR] server stderr: ""

Uninstalled the java extension, which cleaned up ~/Library/Application Support/Zed/extensions/work/java, reloaded Zed, jdtls downloaded properly and bob's your uncle.

Have spent 0 time investigating, but now I can absolutely reproduce what you're seeing.

@valentinegb
Copy link
Collaborator Author

Do you think you could test this same thing with the TOML extension? (Just because I happen to know that one specifically works similarly to the Java extension.)

Also, carry on if uninstallation fails
@valentinegb valentinegb marked this pull request as ready for review December 23, 2024 20:15
@valentinegb
Copy link
Collaborator Author

This shouldn't mess with the installation of other things like Lombok, so it should be safe to merge now. Will fix problems if/when they show up in the future.

@valentinegb valentinegb merged commit f92ae17 into main Dec 23, 2024
1 check passed
@valentinegb valentinegb deleted the auto-update-jdtls branch December 23, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed enhancement New feature or request language-server Related to the language server.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants