Lsp-mode: Error `wrong-type-argument symbolp "generate"` occurs when using gopls

Created on 10 Jun 2020  路  6Comments  路  Source: emacs-lsp/lsp-mode

Describe the bug
When opening a go file with gopls enabled, below error will occur:

Error processing message (wrong-type-argument symbolp "generate").

This error has started seeing since today's lsp-mode update.

To Reproduce
I have below configuration for lsp-mode:

(use-package lsp-mode
  :ensure t
  :hook
  ((go-mode python-mode) . lsp-deferred)
  (lsp-mode . lsp-enable-which-key-integration)

  :defer t

  :config
  (require 'lsp-clients)
  (require 'lsp-go)
  (require 'lsp-pyls)

  (lsp-register-custom-settings
   '(("gopls.completeUnimported" t t)
     ("gopls.staticcheck" t t))))
  1. Make sure corresponding GOPATH is set correctly.
  2. Right after opening a go file, the error will pop up.

Expected behavior
The error should not occur.

Which Language Server did you use

GNU Emacs 27.0.91 (build 1, x86_64-apple-darwin19.5.0, NS appkit-1894.50 Version 10.15.5 (Build 19F101)) of 2020-06-09

Using lsp-mode 20200610.1720

$ gopls version
golang.org/x/tools/gopls 0.4.1
    golang.org/x/tools/[email protected] h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=

OS
Mac OS 10.15.5 (19F101)

Error callstack

Debugger entered--Lisp error: (wrong-type-argument symbolp "generate")
  json-serialize((:jsonrpc "2.0" :id 2 :result [#<hash-table equal 6/65 0x1fff871a968d> nil]) :null-object nil :false-object :json-false)
  lsp--make-message((:jsonrpc "2.0" :id 2 :result [#<hash-table equal 6/65 0x1fff871a968d> nil]))
  lsp--send-request-response(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 20/20 0x1fff88e0e9cd> :registered-server-capabilities (#s(lsp--registered-capability :id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1fff87452329>)) :root "/Users/yuezhu/work/gocode" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1fff8731fd51>) :test\? #f(compiled-function () #<bytecode 0x1fff8731fd65>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1fff8731fd71> :request-handlers #<hash-table equal 0/65 0x1fff87320049> :response-handlers #<hash-table eql 0/65 0x1fff87320339> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1fff87320631> :action-handlers #<hash-table equal 0/65 0x1fff87320929> :major-modes (go-mode go-dot-mod-mode) :activation-fn nil :priority 0 :server-id gopls :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn lsp-clients-go--library-default-directories :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 #<hash-table equal 0/65 0x1fff87320c01> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process gopls> :cmd-proc #<process gopls> :buffers (#<buffer main.go>) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1fff88e734c9> :watches #<hash-table equal 0/65 0x1fff88e736f9> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1fff88e73719> :work-done-tokens #<hash-table equal 0/65 0x1fff88e73739>) (24289 9814 122397 0) #<hash-table equal 4/4 0x1fff89d1d6b9> [#<hash-table equal 6/65 0x1fff871a968d> nil])
  lsp--on-request(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 20/20 0x1fff88e0e9cd> :registered-server-capabilities (#s(lsp--registered-capability :id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1fff87452329>)) :root "/Users/yuezhu/work/gocode" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1fff8731fd51>) :test\? #f(compiled-function () #<bytecode 0x1fff8731fd65>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1fff8731fd71> :request-handlers #<hash-table equal 0/65 0x1fff87320049> :response-handlers #<hash-table eql 0/65 0x1fff87320339> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1fff87320631> :action-handlers #<hash-table equal 0/65 0x1fff87320929> :major-modes (go-mode go-dot-mod-mode) :activation-fn nil :priority 0 :server-id gopls :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn lsp-clients-go--library-default-directories :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 #<hash-table equal 0/65 0x1fff87320c01> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process gopls> :cmd-proc #<process gopls> :buffers (#<buffer main.go>) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1fff88e734c9> :watches #<hash-table equal 0/65 0x1fff88e736f9> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1fff88e73719> :work-done-tokens #<hash-table equal 0/65 0x1fff88e73739>) #<hash-table equal 4/4 0x1fff89d1d6b9>)
  lsp--parser-on-message(#<hash-table equal 4/4 0x1fff89d1d6b9> #s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 20/20 0x1fff88e0e9cd> :registered-server-capabilities (#s(lsp--registered-capability :id "workspace/didChangeWatchedFiles" :method "workspace/didChangeWatchedFiles" :options #<hash-table equal 1/1 0x1fff87452329>)) :root "/Users/yuezhu/work/gocode" :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1fff8731fd51>) :test\? #f(compiled-function () #<bytecode 0x1fff8731fd65>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1fff8731fd71> :request-handlers #<hash-table equal 0/65 0x1fff87320049> :response-handlers #<hash-table eql 0/65 0x1fff87320339> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1fff87320631> :action-handlers #<hash-table equal 0/65 0x1fff87320929> :major-modes (go-mode go-dot-mod-mode) :activation-fn nil :priority 0 :server-id gopls :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn lsp-clients-go--library-default-directories :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 #<hash-table equal 0/65 0x1fff87320c01> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process gopls> :cmd-proc #<process gopls> :buffers (#<buffer main.go>) :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1fff88e734c9> :watches #<hash-table equal 0/65 0x1fff88e736f9> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1fff88e73719> :work-done-tokens #<hash-table equal 0/65 0x1fff88e73739>))
  #f(compiled-function (proc input) #<bytecode 0x1fff88e6cdf1>)(#<process gopls> "Content-Length: 219\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"...")
go

Most helpful comment

After looking at https://github.com/emacs-lsp/lsp-mode/commit/cceafa08eee91735aa7e6f7eebf2c1bddff2a0b7, I have set lsp-gopls-codelens to nil to avoid hitting the error.

All 6 comments

After looking at https://github.com/emacs-lsp/lsp-mode/commit/cceafa08eee91735aa7e6f7eebf2c1bddff2a0b7, I have set lsp-gopls-codelens to nil to avoid hitting the error.

@ibizaman willing to take a look? I think that the keys has to be symbols/keywords for emacs 27 native serialization.

Sorry about that @yuezhu, I鈥檒l take a look this evening @yyoncho

@ibizaman any update on that?

Been encountering this, too.

I think that the keys has to be symbols/keywords for emacs 27 native serialization

For alists, that appears to be the case, which is inconvenient, but there's probably a reason. Original patch and thread from 2017.

@yyoncho sorry while fixing this I dug deep into the rabbit hole of trying to reproduce the issue using automated tests. I鈥檒l instead switch to just fix it with manual tests.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kmdouglass picture kmdouglass  路  3Comments

mcraveiro picture mcraveiro  路  3Comments

bradprob picture bradprob  路  5Comments

axelson picture axelson  路  4Comments

dchneric picture dchneric  路  3Comments