elbywan / crystalline

A Language Server Protocol implementation for Crystal. 🔮
MIT License
424 stars 21 forks source link

Start crystalline failed partially when used with emacs. #83

Closed zw963 closed 5 months ago

zw963 commented 5 months ago

Hi, not use crystalline for a long time, because it not work before, i can see notification said crystalline start successful, the process is really started too.

 ╰─ $ ps aux |grep crystalline
zw963     571897  0.3  0.3 313408 187136 ?       Ssl  04:14   0:00 /home/zw963/Crystal/bin/crystalline --stdio

Even, i can saw breadcrumb showed correctly, but it just not working, no any crystalline support feature available.

I saw crystalline release the new version, so just try it again. but no luck, so, i start thought, maybe this is somewhat option issue, did I enable an option that crystalline does not support?

Following is error message which enable debug-on-error option.


error messages Debugger entered--Lisp error: (wrong-type-argument stringp nil) directory-file-name(nil) lsp-diagnostics--update-path(nil [0 1 0 0 0]) lsp--on-diagnostics-update-stats(#s(lsp--workspace :ewoc #s(ewoc :buffer # :pretty-printer lsp--log-entry-pp :header [[[[... #5 ... #] #4 "" #] #3 DL-LIST #] [#3 [#4 [#5 ... ... #] #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time 105 :type incoming-resp :method "initialize" :id 1 :body #) #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body (:processId 575232 :rootPath "/home/zw963/Crystal/crystal-china/translater" :clientInfo ... :rootUri "file:///home/zw963/Crystal/crystal-china/tra..." :capabilities ... :initializationOptions nil :workDoneToken "1")) #] "" #] :footer [[[[... #5 ... #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "$/progress" :id nil :body #) #] #3 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] [#3 [#4 [#5 ... ... #] "" #] DL-LIST #] "" #] :dll [[[[... #5 ... #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] #3 "" #] [#3 [#4 [#5 ... ... #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body ...) #] "" #] DL-LIST #] :last-node nil :hf-pp insert) :server-capabilities # :registered-server-capabilities nil :root "/home/zw963/Crystal/crystal-china/translater" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn workspace) #) :test? #f(compiled-function () #)) :ignore-regexps nil :ignore-messages nil :notification-handlers # :request-handlers # :response-handlers # :prefix-function nil :uri-handlers # :action-handlers # :major-modes (crystal-mode) :activation-fn nil :priority 0 :server-id crystalline :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers # :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata # :watches # :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics # :work-done-tokens #) #) lsp--on-diagnostics(#s(lsp--workspace :ewoc #s(ewoc :buffer # :pretty-printer lsp--log-entry-pp :header [[[[... #5 ... #] #4 "" #] #3 DL-LIST #] [#3 [#4 [#5 ... ... #] #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time 105 :type incoming-resp :method "initialize" :id 1 :body #) #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body (:processId 575232 :rootPath "/home/zw963/Crystal/crystal-china/translater" :clientInfo ... :rootUri "file:///home/zw963/Crystal/crystal-china/tra..." :capabilities ... :initializationOptions nil :workDoneToken "1")) #] "" #] :footer [[[[... #5 ... #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "$/progress" :id nil :body #) #] #3 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] [#3 [#4 [#5 ... ... #] "" #] DL-LIST #] "" #] :dll [[[[... #5 ... #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] #3 "" #] [#3 [#4 [#5 ... ... #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body ...) #] "" #] DL-LIST #] :last-node nil :hf-pp insert) :server-capabilities # :registered-server-capabilities nil :root "/home/zw963/Crystal/crystal-china/translater" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn workspace) #) :test? #f(compiled-function () #)) :ignore-regexps nil :ignore-messages nil :notification-handlers # :request-handlers # :response-handlers # :prefix-function nil :uri-handlers # :action-handlers # :major-modes (crystal-mode) :activation-fn nil :priority 0 :server-id crystalline :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers # :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata # :watches # :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics # :work-done-tokens #) #) lsp--on-notification(#s(lsp--workspace :ewoc #s(ewoc :buffer # :pretty-printer lsp--log-entry-pp :header [[[[... #5 ... #] #4 "" #] #3 DL-LIST #] [#3 [#4 [#5 ... ... #] #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time 105 :type incoming-resp :method "initialize" :id 1 :body #) #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body (:processId 575232 :rootPath "/home/zw963/Crystal/crystal-china/translater" :clientInfo ... :rootUri "file:///home/zw963/Crystal/crystal-china/tra..." :capabilities ... :initializationOptions nil :workDoneToken "1")) #] "" #] :footer [[[[... #5 ... #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "$/progress" :id nil :body #) #] #3 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] [#3 [#4 [#5 ... ... #] "" #] DL-LIST #] "" #] :dll [[[[... #5 ... #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] #3 "" #] [#3 [#4 [#5 ... ... #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body ...) #] "" #] DL-LIST #] :last-node nil :hf-pp insert) :server-capabilities # :registered-server-capabilities nil :root "/home/zw963/Crystal/crystal-china/translater" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn workspace) #) :test? #f(compiled-function () #)) :ignore-regexps nil :ignore-messages nil :notification-handlers # :request-handlers # :response-handlers # :prefix-function nil :uri-handlers # :action-handlers # :major-modes (crystal-mode) :activation-fn nil :priority 0 :server-id crystalline :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers # :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata # :watches # :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics # :work-done-tokens #) #) lsp--parser-on-message(# #s(lsp--workspace :ewoc #s(ewoc :buffer # :pretty-printer lsp--log-entry-pp :header [[[[... #6 ... #] #5 "" #] #4 DL-LIST #] [#4 [#5 [#6 ... ... #] #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time 105 :type incoming-resp :method "initialize" :id 1 :body #) #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body (:processId 575232 :rootPath "/home/zw963/Crystal/crystal-china/translater" :clientInfo ... :rootUri "file:///home/zw963/Crystal/crystal-china/tra..." :capabilities ... :initializationOptions nil :workDoneToken "1")) #] "" #] :footer [[[[... #6 ... #] #5 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "$/progress" :id nil :body #) #] #4 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] [#4 [#5 [#6 ... ... #] "" #] DL-LIST #] "" #] :dll [[[[... #6 ... #] #5 #s(lsp--log-entry :timestamp "04:27:12 AM" :process-time nil :type incoming-notif :method "textDocument/publishDiagnostics" :id nil :body #) #] #4 "" #] [#4 [#5 [#6 ... ... #] #s(lsp--log-entry :timestamp "04:27:11 AM" :process-time nil :type outgoing-req :method "initialize" :id 1 :body ...) #] "" #] DL-LIST #] :last-node nil :hf-pp insert) :server-capabilities # :registered-server-capabilities nil :root "/home/zw963/Crystal/crystal-china/translater" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn workspace) #) :test? #f(compiled-function () #)) :ignore-regexps nil :ignore-messages nil :notification-handlers # :request-handlers # :response-handlers # :prefix-function nil :uri-handlers # :action-handlers # :major-modes (crystal-mode) :activation-fn nil :priority 0 :server-id crystalline :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers # :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc # :cmd-proc # :buffers (#) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata # :watches # :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics # :work-done-tokens #)) #f(compiled-function (msg) #)(#) mapc(#f(compiled-function (msg) #) (# #)) #f(compiled-function (proc input) #)(# "Content-Length: 320\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"textDocument/publishDiagnostics\",\"params\":{\"uri\":\"file://\",\"diagnostics\":[{\"range\":{\"start\":{\"line\":0,\"character\":-1},\"end\":{\"line\":0,\"character\":-1}},\"severity\":1,\"source\":\"\",\"message\":\"abstract `def Object#hash(hasher)` must be implemented by ReferenceStorage(T)\",\"relatedInformation\":[]}]}}Content-Length: 138\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"$/progress\",\"params\":{\"token\":\"workspace/compile/0\",\"value\":{\"message\":\"Completed with errors.\",\"kind\":\"end\"}}}")

It look's like those error about lsp update diagnostics status? but, i checked the README, it said, crystalline support diagnostics, right?

BTW: there should not a emacs config issue, at least, the emacs lsp for go, rust use same settings, work quite well.

My emacs lsp settings is here

thanks.

elbywan commented 5 months ago

Hey @zw963,

It look's like those error about lsp update diagnostics status?

I can see this error in the logs: def Object#hash(hasher) must be implemented by ReferenceStorage(T)

It seems related to the following crystal bug: https://github.com/crystal-lang/crystal/issues/14194. Since crystalline uses v1.11.0 to compile your program, maybe you are using an older crystal version?

crystalline support diagnostics, right?

Yes, when crystalline is setup correctly. This is how it looks like on my end with vscode:

https://github.com/elbywan/crystalline/assets/3428394/ab16f67a-bec1-4cab-97d7-d45f64ff5c35

zw963 commented 5 months ago

Yes, when crystalline is setup correctly. This is how it looks like on my end with vscode:

Wow,really awesome show case!

It seems related to the following crystal bug: https://github.com/crystal-lang/crystal/issues/14194. Since crystalline uses v1.11.0 to compile your program, maybe you are using an older crystal version?

In fact, i use Crystal 1.1.2, and always compile the Crystal compiler myself.

 ╰─ $ crystal --version
Crystal 1.11.2 [fda656c71] (2024-01-18)

LLVM: 16.0.6
Default target: x86_64-pc-linux-gnu

but, i download crystalline from release page, because compile is slow, let me try compile it from source, and will report here.

zw963 commented 5 months ago

Done, it spent six minutes for build a dynamic version crystalline.

 ╰─ $ ldd crystalline
        linux-vdso.so.1 (0x00007ffeb00ce000)
        libyaml-0.so.2 => /usr/lib/libyaml-0.so.2 (0x00007ffb7efbe000)
        libLLVM-16.so => /usr/lib/libLLVM-16.so (0x00007ffb76000000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007ffb75c00000)
        libpcre2-8.so.0 => /usr/lib/libpcre2-8.so.0 (0x00007ffb7ef23000)
        libm.so.6 => /usr/lib/libm.so.6 (0x00007ffb75f13000)
        libgc.so.1 => /usr/lib/libgc.so.1 (0x00007ffb75ea7000)
        libevent_pthreads-2.1.so.7 => /usr/lib/libevent_pthreads-2.1.so.7 (0x00007ffb7ef1c000)
        libevent-2.1.so.7 => /usr/lib/libevent-2.1.so.7 (0x00007ffb75bae000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007ffb75e82000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007ffb759cc000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007ffb7f00a000)
        libffi.so.8 => /usr/lib/libffi.so.8 (0x00007ffb7ef11000)
        libedit.so.0 => /usr/lib/libedit.so.0 (0x00007ffb75990000)
        libz.so.1 => /usr/lib/libz.so.1 (0x00007ffb7e3e6000)
        libzstd.so.1 => /usr/lib/libzstd.so.1 (0x00007ffb758bd000)
        libncursesw.so.6 => /usr/lib/libncursesw.so.6 (0x00007ffb75846000)
        libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00007ffb756dc000)
        libevent_core-2.1.so.7 => /usr/lib/libevent_core-2.1.so.7 (0x00007ffb756aa000)
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0x00007ffb75677000)
        libicuuc.so.74 => /usr/lib/libicuuc.so.74 (0x00007ffb75400000)
        libicudata.so.74 => /usr/lib/libicudata.so.74 (0x00007ffb73600000)

 ╰─ $ file crystalline
crystalline: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=0c82e60e9a5a023dab725a87d24cf2deec32e873, for GNU/Linux 4.4.0, not stripped

It works for me now!

I double confirm to switch back to use the github release version, still get same error.

So, any idea?

image

elbywan commented 5 months ago

It works for me now!

Great 😄

I double confirm to switch back to use the github release version, still get same error.

I suppose it's because the linux release binary is built with crystal v1.11.0, I'll bump the crystal version on the CI to v1.11.2 and publish again.

elbywan commented 5 months ago

@zw963 Can you try with this binary from the latest build?

zw963 commented 5 months ago

@zw963 Can you try with this binary from the latest build?

It works!