nsf / gocode

An autocompletion daemon for the Go programming language
MIT License
5.01k stars 656 forks source link

Company: backend company-go error "Wrong type argument: stringp, nil" with args (candidates ) #477

Closed stefancocora closed 6 years ago

stefancocora commented 6 years ago

Thank you for gocode !

I've updated to the latest version of gocode and restarted emacs various times to take the debug snapshots but this still doesn't fix the issue.

The error I'm seeing when company-go gets activated

Company: An error occurred in auto-begin
Company: backend company-go error "Wrong type argument: stringp, nil" with args (candidates )
Company: An error occurred in auto-begin
Company: backend company-go error "Wrong type argument: stringp, nil" with args (candidates E)

Versions of software:

GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-30
Spacemacs v.0.200.9 - develop branch
company: 20170926.1515 == 0.9.4
company-go: 20170825.943
go: 1.9
gocode: c7fddb39ecbc9ebd1ebe7d2a3af473ed0fffffa1

When activating the autocompletion with company-go by typing t.


Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  propertize(nil meta "Found 17 candidates:  " package nil)
  #[(str) "\302\303\"\304 A@\305\306  !\307\310   8%)\207" [str candidate split-string ",," propertize meta company-go--format-meta package 3] 7]("Found 17 candidates:")
  mapcar(#[(str) "\302\303\"\304  A@\305\306  !\307\310   8%)\207" [str candidate split-string ",," propertize meta company-go--format-meta package 3] 7] ("Found 17 candidates:" "  func Error(args ...interface{})" "  func Errorf(format string, args ...interface{})" "  func Fail()" "  func FailNow()" "  func Failed() bool" "  func Fatal(args ...interface{})" "  func Fatalf(format string, args ...interface{})" "  func Helper()" "  func Log(args ...interface{})" "  func Logf(format string, args ...interface{})" "  func Name() string" "  func Parallel()" "  func Run(name string, f func(t *testing.T)) bool" "  func Skip(args ...interface{})" "  func SkipNow()" "  func Skipf(format string, args ...interface{})" "  func Skipped() bool"))
  company-go--get-candidates(("Found 17 candidates:" "  func Error(args ...interface{})" "  func Errorf(format string, args ...interface{})" "  func Fail()" "  func FailNow()" "  func Failed() bool" "  func Fatal(args ...interface{})" "  func Fatalf(format string, args ...interface{})" "  func Helper()" "  func Log(args ...interface{})" "  func Logf(format string, args ...interface{})" "  func Name() string" "  func Parallel()" "  func Run(name string, f func(t *testing.T)) bool" "  func Skip(args ...interface{})" "  func SkipNow()" "  func Skipf(format string, args ...interface{})" "  func Skipped() bool"))
  company-go--candidates()
  company-go(candidates "")
  apply(company-go (candidates ""))
  company-call-backend-raw(candidates "")
  company--fetch-candidates("")
  company-calculate-candidates("")
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer sum_test.go> #<window 58 on sum_test.go> 90 110)
  apply(company-idle-begin (#<buffer sum_test.go> #<window 58 on sum_test.go> 90 110))
  timer-event-handler([t 22992 2360 794945 nil company-idle-begin (#<buffer sum_test.go> #<window 58 on sum_test.go> 90 110) nil 414000])
  recursive-edit()
  debug(debug)
  debug--implement-debug-on-entry()
  apply(debug--implement-debug-on-entry nil)
* company-mode()
  (lambda nil (set (make-local-variable (quote company-backends)) (quote (company-go))) (company-mode))()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook go-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook go-mode-hook))
  run-mode-hooks(go-mode-hook)
  go-mode()
  set-auto-mode-0(go-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer sum_test.go> "redacted_path/sum/sum_test.go" nil nil "redacted_path/sum/sum_test.go" (13901820 65024))
  find-file-noselect("redacted_path/sum/sum_test.go" nil nil nil)
  find-file("redacted_path/sum/sum_test.go")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)

Possibly related issues:

nsf commented 6 years ago

Looks like it's an old version of the gocode. Make sure you actually run the latest one.

The logic is the following:

  1. Latest company-go was switched to a newly introduced formatter: csv-with-package.
  2. I see in your debug output: "Found 17 candidates", which is usually printed if nice formatter is used. This formatter is also picked up if you provide an unknown formatter as an argument.
  3. Hence you run an older gocode version which doesn't have csv-with-package yet.

I am sorry about breaking it, but it's just how it is, there is no single path to upgrade both parts of the software. You either use latest company-go with latest gocode or older company-go script with older gocode.

After updating gocode, don't forget to kill the server which might be running: gocode close. New one will start automatically. Also make sure there is only one gocode binary on your PATH: which -a gocode.

stefancocora commented 6 years ago

Looks like it's an old version of the gocode. Make sure you actually run the latest one.

As far as I can see I am running the latest version of gocode and that is why I put the git shasum in my previous post.

My local gocode version

gocode: c7fddb39ecbc9ebd1ebe7d2a3af473ed0fffffa1

Looks like I have the latest gocode with the csv-with-package formatter

ag 'csv-with-package' ./

emacs-company/company-go.el
74:                             (list "-f=csv-with-package"

formatters.go
178:    case "csv-with-package":
...

Latest gocode commit in github - https://github.com/nsf/gocode/commit/c7fddb39ecbc9ebd1ebe7d2a3af473ed0fffffa1

c7fddb39ecbc9ebd1ebe7d2a3af473ed0fffffa1

As far as I can see I'm also running the latest version of company-go

I've ran gocode close , restarted emacs server, ran emacs without a server, all kinds of scenarios ... until ....

I've looked at your last suggestion about multiple gocode binaries in my $PATH !

Upon verifying this possibility, I've discovered that a once installed liteide package installed its own gocode binary , leaving my system in a state with 2 gocode binaries in my path. The fix was to remove liteide ( which I don't use anyway ) After removing liteide with its own bundled gocode the aut-completion started working again as it was previously. 👍

for i in `which -a gocode`; do sha512sum $i ; done                
c834bc6273efa2948da8595eecd322a550db3cd6081d3212a73fa2902b2b9d91ab5f26ce466708023ccefe961ddd4716d89f505eaa967e3c0001f7cd54d61e53  /usr/bin/gocode                                                                                                                                 
8c8c39e5eb439d35f621cb68b79a7373095add575e059d55c548a96ef90ecf1cedbcee95b11369491eb892b3feb674db1d072c2c350655fcb880fdc0d4d081d8 $GOPATH/bin/gocode
...
pkgfile -s /usr/bin/gocode                                                                                                             
community/liteide
...
sudo pacman -R liteide

Thank you for gocode and for your patience ! 👍 \\//