emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
650 stars 90 forks source link

Emacs frozen after "Connected to [jdtls:25800 status:starting]" #156

Open juanluis-lightneer opened 5 years ago

juanluis-lightneer commented 5 years ago

I installed lsp-java in emacs 26.3, windows, downloaded the latest server (jdt-language-server-0.43.0-201909120950.tar.gz) and updated all emacs packages. When I open a java file I get the message "LSP :: Connected to [jdtls: status:starting]" and Emacs hangs indefinitely. Is there a way to find the error? I tried running the server myself and seems to execute well, did like this:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=820 -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar ./plugins/org.eclipse.equinox.launcher_1.5.500.v20190715-1310.jar -configuration ./config_win -data ../../tmp/

yyoncho commented 5 years ago

M-x toggle-debug-on-quit and then C-g will show you where emacs has stopped.

juanluis-lightneer commented 5 years ago

When I open the file and see the message (LSP:: Connected to...) it's already too late and it's not responsive anymore. If I do it really quickly (before the message) I don't get any meaningful information, but if I try opening the file again I see some kind of loading bar (next to "[(Java//l|") that I assume means connecting to LSP. By the way, thanks for so quick reply :)

yyoncho commented 5 years ago

You should do M-x toggle-debug-on-quit before calling lsp and press C-g when emacs stuck.

juanluis-lightneer commented 5 years ago

Ok, this is what I do, hope is correct way:

  • Open Emacs
  • M-x toggle-debug-on-quit
  • Open the java file in my project (which triggers the server start)
  • --- Here it freezes --
  • Press C-g

At this point it stays frozen, it doesn't update the window. On the other hand, if I set M-x toggle-debug-on-error it works and shows this error:

Debugger entered--Lisp error: (file-error "Removing directory" "Directory not empty" "c:/Users/user/eclipse-workspace/Test/src") delete-directory-internal("c:/Users/user/eclipse-workspace/Test/src") apply(delete-directory-internal "c:/Users/user/eclipse-workspace/Test/src") files--force(nil delete-directory-internal "c:/Users/user/eclipse-workspace/Test/src") delete-directory("c:/Users/user/eclipse-workspace/Test/src") ...

Maybe this helps? After this I seem to get autocomplete working in the test file I have.

juanluis-lightneer commented 5 years ago

Ok, I did in Linux with a gradle created project and it worked. I will try on windows machine as soon as possible but I guess that was the problem

yyoncho commented 5 years ago

@juanluis-lightneer probably is the same issue as https://github.com/emacs-lsp/lsp-mode/issues/514 . Unfortunately, I am not a windows user and I am out of options for that issue.

juanluis-lightneer commented 5 years ago

@yyoncho Ok, no problem :) I will keep trying things and update if I get something, for now I know it also happens with gradle created project in windows but not in Linux. Not a big deal since I work with csharp 99.9% of the time. Thanks!

hectorhon commented 3 years ago

I am facing the same issue on Emacs 27.1, and using toggle-debug-on-error I was able to narrow it down to something with lsp and flymake. My source file is a single App.java (opened with find-file, not yet saved) file in the directory c:/Users/hectorhon/repo/temp.

Packages:

lsp-mode           20210311.814  installed             LSP mode
lsp-java           20210309.1856 installed             Java support for lsp-mode
flymake            1.0.8         built-in              A universal on-the-fly syntax checker
Debugger entered--Lisp error: (file-error "Removing directory" #("Permission denied" 0 17 (charset windows-1252)) "c:/Users/hectorhon/repo/temp")
  delete-directory-internal("c:/users/hectorhon/repo/temp")
  ...
  flymake-proc--safe-delete-directory("c:/users/hectorhon/repo/temp")
  flymake-proc--delete-temp-directory("c:/Users/hectorhon/AppData/Local/Temp/Users/hector...")
  flymake-proc-simple-java-cleanup()
  ...
  flymake-start(t)
  flymake-mode(1)
  lsp-diagnostics--flymake-setup()
  ...

(That was a handful to type since Emacs freezes immediately after that...)

Now, I am not sure why flymake tries to delete the source directory! To verify, Emacs no longer freezes on startup when I install flycheck and lsp picks that up. I am using that as a workaround at the moment.

Just dropping this information here, hoping someone with more knowledge on the modes will dig the rabbit hole!

chookity-pokk commented 1 year ago

@hectorhon When you say lsp is picking up flyckeck, what do you mean? I am having the same error and can't seem to get rid of it. I can read a buffer just fine, but trying to edit it causes it to freeze.

Odly enough though, when I run the given debug command, I get the below output. Which is quite different from the command you two seem to have gotten.

  re-search-backward("^\\s(\\|\\(?:^[ \11]*\\(\\(\\(public\\|protected\\|private\\|..." nil move 1)
  beginning-of-defun-raw(nil)
  beginning-of-defun()
  c-get-fallback-scan-pos(5076)
  c-parse-state-get-strategy(5076 1)
  c-parse-state-1()
  c-parse-state()
  c-electric-brace(nil)
  funcall-interactively(c-electric-brace nil)
  call-interactively(c-electric-brace nil nil)
  command-execute(c-electric-brace)