Closed JHicks01 closed 2 years ago
Are you using emacs 29 from master?
Are you using emacs 29 from master?
No, emacs 28.1:
GNU Emacs 28.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0) of 2022-06-11
What is the rust-analyzer version you are using ? There was a release even two days ago, so letting us know an explicit version would help us:
❯ rust-analyzer --version
rust-analyzer 2022-06-13
What is the rust-analyzer version you are using ? There was a release even two days ago, so letting us know an explicit version would help us:
❯ rust-analyzer --version rust-analyzer 2022-06-13
rust-analyzer 0.3.1131-standalone (897a7ec4b 2022-07-17)
If it helps, I just tried with rls instead of rust-analyzer, and got a similar error:
[2022-07-22T19:43:52Z ERROR rls::server] dispatch error: Error { code: InvalidParams, message: "invalid type: map, expected u64", data: None }
So doesn't seem to be related to the language server itself.
Can you paste what is the output if this M-: (lsp--json-serialize (list :processId nil)) RET
Can you paste what is the output if this
M-: (lsp--json-serialize (list :processId nil)) RET
"{\"processId\":{}}"
This should return null
instead of {}
. I compiled emacs from master, emacs from 28.1 branches and it still works fine. I don't have a clue why it works like that on your side.
How did you obtain that version of emacs?
Built emacs-28.1 release.
I just tried uninstalling and rebuilding, same thing happens.
Can you give me the exact commit
Can you give me the exact commit
Sorry, I was just using the release from e.g. http://ftp.gnu.org/gnu/emacs/. I'll try again later with e.g. latest commit of the 28 branch.
Can you give me the exact commit
Just tried with #2529e8200232aa8ce252084634d81a2809fb26fa (https://github.com/emacs-mirror/emacs/commit/2529e8200232aa8ce252084634d81a2809fb26fa)
Still get the same error.
can you tell me what is your jansson library version?
can you tell me what is your jansson library version?
Is that a dependency of something? I don't appear to have it installed.
FYI - same thing on emacs master. I guess something with my setup must be wrong but I have no idea what it could be.
The issue is that json-serialize a function written in C and calling jansson library is misbehaving. It doesn't serialize nil as json null but it serializes it to {}
. Given the fact that I cannot reproduce with that same emacs commit then I believe that it might be caused by something external (e. g. Jansson library itself).
The issue is that json-serialize a function written in C and calling jansson library is misbehaving. It doesn't serialize nil as json null but it serializes it to
{}
. Given the fact that I cannot reproduce with that same emacs commit then I believe that it might be caused by something external (e. g. Jansson library itself).
Thank you for the pointers. You are right, looks like it was the fault of that lib. It looks like I had a different version installed, which must not have been working for whatever reason (I'm not familiar enough with any of this to diagnose).
After installing the libjansson-dev package, it seems to work.
Strangely, I also tried using the --with-json=no
option when building emacs, which, unless I misunderstand, should avoid using the lib, but this still resulted in the same error.
Anyway, I'll close this now as it appears to be fine with the package installed. Thank you for the help!
I was wasting quite a lot of time fixing this issue with texlab and am not sure about what actually fixed it for me. But for anyone also having this problem, be sure to reinstall lsp-mode (e.g. by rm -rf ~/.emacs.d/elpa/develop/lsp-mode-20220727.817/
or similar) to recompile the lisp bytecode.
FYI, (lsp--json-serialize (list :processId nil))
is still giving "{\"processId\":{}}"
for me, but lsp works nevertheless (null gets transmitted).
I had the same issue with lsp-clojure
(see https://github.com/clojure-lsp/clojure-lsp/issues/1197) ad solved it in the same way, by installing the libjansson-dev
package from my OS package manager. It seems to me that lsp-mode
(at least with some language servers?) fails in an unexpected and hard-to-diagnose way if emacs is not built against libjansson
, so would it be possible somehow to have the installation of lsp-mode
fail if this library isn't available, if it's true that it will not function correctly without it? I don't know enough to say that that's a fact, though.
@maddenp based on this comment(and few other) it seems like there is version of json.el (emacs elisp json handling library) which serializes nil to {}. Can someone attach the json.el version that is causing the trouble(use M-x find-library)?
On my system the following ...
(let ((json-false :json-false))
(json-encode '(:a nil)))
... returns {"a":null}
Hi @yyoncho. On a system where I can reproduce the lsp-clojure
issue, that bit of elisp also returns {"a":null}
, so I suspect it won't help, but I'm attaching the file returned by find-library
on json.el
. If there's anything else I can try or help with, I'd be happy to.
json.el.gz
@maddenp hm... that's odd. (lsp--json-serialize (list :processId nil))
is already working correctly, right?
On my good system, (lsp--json-serialize (list :processId nil))
returns {"processId":null}
. On the problem system, it returns {"processId":{}}
. Looking the source of lsp--json-serialize
, there's a conditional that calls either json-encode
or json-serialize
. The former encodes nil
-> null
as discussed above, but the latter -- which appears to be the preferred option, called if defined -- encodes nil
-> {}
, and it looks like that's what's being called. It doesn't seem to honor the :null-object
value passed in by lsp--json-serialize
as advertised, but my elisp knowledge is getting thin here.
I got the same error when I initially compiled https://github.com/emacs-ng/emacs-ng and used that version of emacs (I'm running Fedora 36).
However, after installing jansson-devel
:
sudo dnf install jansson-devel
and recompiling, everything works as expected.
Thank you for the bug report
lsp-mode
related packages.M-x lsp-start-plain
Bug description
lsp-rust: rust-analyzer fails on startup with the following error:
[ERROR rust_analyzer] Unexpected error: Failed to deserialize InitializeParams: invalid type: map, expected u32;
Steps to reproduce
I'm using latest versions of all packages, and can reproduce by opening main.rs in a new/empty rust project.
Expected behavior
Not to see the error, rust-analyzer to startup correctly
Which Language Server did you use?
lsp-rust with rust-analyzer
OS
Linux
Error callstack
No response
Anything else?
No response