Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong type argument: listp, "-Wall -Werror" #32

Closed
rememberYou opened this issue Feb 23, 2019 · 6 comments
Closed

Wrong type argument: listp, "-Wall -Werror" #32

rememberYou opened this issue Feb 23, 2019 · 6 comments
Labels
invalid This doesn't seem right

Comments

@rememberYou
Copy link

First of all, I would like to thank you for your work for the community.

As a GNU Emacs user, until now, I have always used eglot as a client for LSP servers by configuring it like this:

(use-package eglot
  :hook (prog-mode . eglot-ensure)
  :custom
  (company-backends (cons 'company-capf
                          (remove 'company-capf company-backends)))
  (company-clang-modes nil))

It worked perfectly, all that remained to be done was to install ccls using the package manager of my operating system and eglot used ccls each time a .cpp or a .c file was opened.

However, I wanted to try lsp-mode by following the instructions on the wiki page and I couldn't get lsp-mode and ccls to work together.

Here is the configuration I have for them:

(use-package lsp-mode
  :hook (prog-mode . lsp))

(use-package lsp-ui
  :after lsp-mode
  :hook (lsp-mode . lsp-ui-mode))

(use-package company-lsp
  :after company lsp-mode
  :config (push 'company-lsp company-backends))

(use-package ccls
  :after projectile
  :ensure-system-package ccls
  :custom
  (ccls-executable (executable-find "ccls"))
  (ccls-sem-highlight-method 'font-lock)
  (projectile-project-root-files-top-down-recurring
   (append '("compile_commands.json" ".ccls")
           projectile-project-root-files-top-down-recurring))
  :config (push ".ccls-cache" projectile-globally-ignored-directories))

For the test, I created a simple foo folder that includes a main.cpp file and a git repository. This choice, in order to avoid providing any compile_commands.json and/or .ccls files to facilitate debugging.

When the main.cpp file is opened and I run lsp, I get this error:
Wrong type argument: listp, "-Wall -Werror"

If I decide to comment on the use of the ccls package in my GNU Emacs configuration, then lsp-mode will work, but will it use the clang language server instead of ccls. So I conclude that I have a problem in my configuration with ccls.

Do you have any idea how to solve this problem? Do not hesitate if you need various information for debugging.

@MaskRay
Copy link
Member

MaskRay commented Feb 23, 2019

Wrong type argument: listp, "-Wall -Werror"

Did you specify -Wall -Werror in compile_commands.json or .ccls?

This choice, in order to avoid providing any compile_commands.json and/or .ccls files to facilitate debugging.

Neither compile_commands.json nor .ccls is mandatory. See https://github.com/MaskRay/ccls/wiki/Project-Setup But ensure (lsp--suggest-project-root) return the correct project root.

A minimal example is: mkdir /tmp/c; cd /tmp/c; git init; echo 'int a;' > a.cc

Open a.cc, and execute M-x lsp

@MaskRay MaskRay closed this as completed Feb 23, 2019
@rememberYou
Copy link
Author

rememberYou commented Feb 23, 2019

Thank you for your quick answer.

I have created the ccls file at /tmp/c that contains the following content:

clang
%c -std=c11
-Wall
-Werror

NOTE: I started from your example and I did not generate the recommanded compile_commands.json file with CMake since this folder does not have a CMakeLists.txt file.

However, after restarting GNU Emacs, opening the /tmp/c/a.cc file and execute M-x lsp, but the error is still the same.

As requested, I have checked that the (lsp--suggest-project-root) function returns the right path. To do this, I changed the mode of the file for lisp-mode and executed this function that sends me back: "/tmp/c/"

If it can help:

M-x emacs-version
GNU Emacs 26.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30) of 2018-07-05
$ uname -a
Linux ThinkPad 4.20.11-arch1-1-ARCH #1 SMP PREEMPT Wed Feb 20 21:11:12 UTC 2019 x86_64 GNU/Linux
$ ccls --version
ccls version 7.0.1 (tags/RELEASE_701/final)

@MaskRay
Copy link
Member

MaskRay commented Feb 23, 2019

-Werror

Unrelated to this issue report, but just wanted to mention that -Werror is probably not the flag you want to add to .ccls. If for some reason clang cannot parse your source file (sometimes due to gcc compatibility, sometimes due to clang's own bugs when some clang features like preamble being used), By default, clang stops parsing the file when it encounters 19 errors (cc1 flag: -ferror-limit 19).

M-x toggle-debug-on-error and try again.

@rememberYou
Copy link
Author

rememberYou commented Feb 23, 2019

This is what M-x toggle-debug-on-error provides me after opened back the /tmp/c/a.cc file:

Debugger entered--Lisp error: (wrong-type-argument listp "-Wall -Werror")
  make-process(:name "ccls" :connection-type pipe :buffer "*ccls*" :coding no-conversion :command ("/usr/bin/ccls" . "-Wall -Werror") :filter #f(compiled-function (proc output) #<bytecode 0x18031b1>) :sentinel #f(compiled-function (process exit-str) #<bytecode 0x1803c41>) :stderr "*ccls::stderr*" :noquery t)
  #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>)(#f(compiled-function (proc output) #<bytecode 0x18031b1>) #f(compiled-function (process exit-str) #<bytecode 0x1803c41>) "ccls")
  lsp--start-workspace(#s(lsp-session :folders ("/tmp/c/" "~/Desktop/test/" "/home/someone/Desktop/test/" "~/.local/share/git/sfml-game/" "/home/someone/.local/share/git/sfml-game/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x15fdd39> :folder->servers #<hash-table equal 0/65 0x185bd8d> :metadata #<hash-table equal 0/65 0x13fcef9>) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil) "/tmp/c/" nil)
  lsp--start-connection(#s(lsp-session :folders ("/tmp/c/" "~/Desktop/test/" "/home/someone/Desktop/test/" "~/.local/share/git/sfml-game/" "/home/someone/.local/share/git/sfml-game/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x15fdd39> :folder->servers #<hash-table equal 0/65 0x185bd8d> :metadata #<hash-table equal 0/65 0x13fcef9>) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil) "/tmp/c/")
  #f(compiled-function (client) #<bytecode 0x1b25365>)(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil))
  mapcar(#f(compiled-function (client) #<bytecode 0x1b25365>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil)))
  -map(#f(compiled-function (client) #<bytecode 0x1b25365>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil)))
  lsp--ensure-lsp-servers(#s(lsp-session :folders ("/tmp/c/" "~/Desktop/test/" "/home/someone/Desktop/test/" "~/.local/share/git/sfml-game/" "/home/someone/.local/share/git/sfml-game/") :folders-blacklist nil :server-id->folders #<hash-table equal 0/65 0x15fdd39> :folder->servers #<hash-table equal 0/65 0x185bd8d> :metadata #<hash-table equal 0/65 0x13fcef9>) (#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name) #<bytecode 0x1848d59>) :test\? #f(compiled-function () #<bytecode 0x184893d>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 2/65 0x1848949> :request-handlers #<hash-table equal 0/65 0x18bd1f9> :response-handlers #<hash-table eql 0/65 0x18bd219> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x187b141> :action-handlers #<hash-table equal 0/65 0x187b161> :use-native-json nil :major-modes (c-mode c++-mode cuda-mode objc-mode) :activation-fn nil :priority 0 :server-id ccls :multi-root nil :initialization-options #f(compiled-function () #<bytecode 0x1781705>) :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil)) "/tmp/c/" nil)
  lsp--try-project-root-workspaces(nil)
  lsp()
  run-hooks(change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c++-mode-hook)
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook c-mode-common-hook c++-mode-hook))
  run-mode-hooks(c++-mode-hook)
  c++-mode()
  set-auto-mode-0(c++-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer a.cc> "/tmp/c/a.cc" nil nil "/tmp/c/a.cc" (248214 48))
  find-file-noselect("/tmp/c/a.cc" nil nil nil)
  find-file("/tmp/c/a.cc")
  dired-find-file()
  funcall-interactively(dired-find-file)
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)

NOTE: I generally use gccto compile my .c and .cpp files, so I changed clang for gcc in the .ccls file. However, clang a.cc works fine in a terminal.

This is the .ccls file with these modifications:

gcc
%c -std=c11
-Wall

One thing I don't understand is how and why I have to provide the -Wall and -Werror flags if I haven't specified to use them everywhere.

In fact, these flags are only defined as compilation options in a CMakeLists.txt file that I specified in another C++ project (sfml-game) where I also tried to use lsp-mode and ccls. That's why, I tried with a minimal project, in vain.

@MaskRay
Copy link
Member

MaskRay commented Feb 23, 2019

ccls-args is a list of strings. Don't use (setq ccls-args "-Wall -Werror")

@MaskRay MaskRay transferred this issue from MaskRay/ccls Feb 23, 2019
@MaskRay MaskRay added the invalid This doesn't seem right label Feb 23, 2019
@rememberYou
Copy link
Author

A huge thank you for your patience and help. Indeed, the arguments of ccls-args was the error. I wonder how it could have been redefined because I don't use it anywhere in my GNU Emacs configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants