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

CL assertion fails via lsp-start-plain -> lsp-install-server #3415

Closed
3 tasks done
dustinpaluch opened this issue Mar 17, 2022 · 7 comments · Fixed by #4115
Closed
3 tasks done

CL assertion fails via lsp-start-plain -> lsp-install-server #3415

dustinpaluch opened this issue Mar 17, 2022 · 7 comments · Fixed by #4115
Labels

Comments

@dustinpaluch
Copy link

dustinpaluch commented Mar 17, 2022

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

lsp-install-server encounters a cl-assertion-failed error when invoked from a lsp-start-plain emacs.

Steps to reproduce

I did M-x lsp-start-plain, which spawned a new emacs process. From this emacs, I did M-x lsp-install-server.

Expected behavior

I expected to get a minibuffer asking me to choose a server to install.

Which Language Server did you use?

N/A

OS

MacOS, 11.6
Emacs 27.1

Error callstack

With lsp-print-io set to t, I only get

Command "rust-analyzer" is not present on the path.
Command "rust-analyzer" is not present on the path.

In the *lsp-log* buffer.

The full backtrace is:
Debugger entered--Lisp error: (cl-assertion-failed ((seq-every-p (apply-partially #'stringp) command) "Invalid command list"))
  cl--assertion-failed((seq-every-p (apply-partially #'stringp) command) "Invalid command list" nil nil)
  (or (seq-every-p (apply-partially #'stringp) command) (cl--assertion-failed '(seq-every-p (apply-partially #'stringp) command) "Invalid command list" (list) (list)))
  (progn (or (seq-every-p (apply-partially #'stringp) command) (cl--assertion-failed '(seq-every-p (apply-partially #'stringp) command) "Invalid command list" (list) (list))) nil)
  (cond ((listp command) (progn (or (seq-every-p (apply-partially #'stringp) command) (cl--assertion-failed '(seq-every-p (apply-partially ...) command) "Invalid command list" (list) (list))) nil) command) ((stringp command) (list command)) ((error "cl-etypecase failed: %s, %s" command '(list string)) nil))
  (let* ((command (if (functionp command) (funcall command) command))) (cond ((listp command) (progn (or (seq-every-p (apply-partially #'stringp) command) (cl--assertion-failed '(seq-every-p ... command) "Invalid command list" (list) (list))) nil) command) ((stringp command) (list command)) ((error "cl-etypecase failed: %s, %s" command '(list string)) nil)))
  lsp-resolve-final-function((closure (t) nil (list (or (executable-find lsp-perlnavigator-executable) (lsp-package-path 'perlnavigator)) "--stdio")))
  (lsp-server-present\? (lsp-resolve-final-function command))
  (closure ((test-command) (command closure (t) nil (list (or (executable-find lsp-perlnavigator-executable) (lsp-package-path 'perlnavigator)) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) nil (lsp-server-present\? (lsp-resolve-final-function command)))()
  funcall((closure ((test-command) (command closure (t) nil (list (or (executable-find lsp-perlnavigator-executable) (lsp-package-path 'perlnavigator)) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) nil (lsp-server-present\? (lsp-resolve-final-function command))))
  (progn (funcall result))
  (if result (progn (funcall result)))
  (let ((result (let ((result (let (...) (if result ...)))) (if result (progn (plist-get result :test\?)))))) (if result (progn (funcall result))))
  (condition-case nil (let ((result (let ((result (let ... ...))) (if result (progn (plist-get result :test\?)))))) (if result (progn (funcall result)))) (error nil) (args-out-of-range nil))
  (if (equal (progn (or (and (memq (type-of client) cl-struct-lsp--client-tags) t) (signal 'wrong-type-argument (list 'lsp--client client))) (aref client 15)) 'lsp-pwsh) nil (condition-case nil (let ((result (let ((result ...)) (if result (progn ...))))) (if result (progn (funcall result)))) (error nil) (args-out-of-range nil)))
  lsp--server-binary-present\?(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (filter sentinel name environment-fn) (let ((final-command (lsp-resolve-final-function command)) (process-name (generate-new-buffer-name name)) (process-environment (lsp--compute-process-environment environment-fn))) (let* ((stderr-buf ...) (proc ...)) (set-process-query-on-exit-flag proc nil) (set-process-query-on-exit-flag (get-buffer-process stderr-buf) nil) (save-current-buffer (set-buffer ...) (special-mode)) (cons proc proc)))) :test\? (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ffe724c029d> :request-handlers #<hash-table equal 0/65 0x1ffe724c02bd> :response-handlers #<hash-table eql 0/65 0x1ffe724c02dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ffe709b66c1> :action-handlers #<hash-table equal 0/65 0x1ffe709da699> :major-modes nil :activation-fn (closure ((languages "perl") cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (_file-name _mode) (-contains\? languages (lsp-buffer-language))) :priority 0 :server-id perlnavigator :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 #<hash-table equal 0/65 0x1ffe709b7ec1> :download-server-fn (closure (t) (_client callback error-callback _update\?) (lsp-package-ensure 'perlnavigator callback error-callback)) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  (if (lsp--server-binary-present\? client) (concat server-name " (Already installed)") server-name)
  (let ((server-name (symbol-name (progn (or (and (memq ... cl-struct-lsp--client-tags) t) (signal 'wrong-type-argument (list ... client))) (aref client 15))))) (if (lsp--server-binary-present\? client) (concat server-name " (Already installed)") server-name))
  (closure ((server-id) (update\?) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (client) (let ((server-name (symbol-name (progn (or ... ...) (aref client 15))))) (if (lsp--server-binary-present\? client) (concat server-name " (Already installed)") server-name)))(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (filter sentinel name environment-fn) (let ((final-command (lsp-resolve-final-function command)) (process-name (generate-new-buffer-name name)) (process-environment (lsp--compute-process-environment environment-fn))) (let* ((stderr-buf ...) (proc ...)) (set-process-query-on-exit-flag proc nil) (set-process-query-on-exit-flag (get-buffer-process stderr-buf) nil) (save-current-buffer (set-buffer ...) (special-mode)) (cons proc proc)))) :test\? (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ffe724c029d> :request-handlers #<hash-table equal 0/65 0x1ffe724c02bd> :response-handlers #<hash-table eql 0/65 0x1ffe724c02dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ffe709b66c1> :action-handlers #<hash-table equal 0/65 0x1ffe709da699> :major-modes nil :activation-fn (closure ((languages "perl") cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (_file-name _mode) (-contains\? languages (lsp-buffer-language))) :priority 0 :server-id perlnavigator :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 #<hash-table equal 0/65 0x1ffe709b7ec1> :download-server-fn (closure (t) (_client callback error-callback _update\?) (lsp-package-ensure 'perlnavigator callback error-callback)) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  funcall((closure ((server-id) (update\?) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (client) (let ((server-name (symbol-name (progn (or ... ...) (aref client 15))))) (if (lsp--server-binary-present\? client) (concat server-name " (Already installed)") server-name))) #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (filter sentinel name environment-fn) (let ((final-command (lsp-resolve-final-function command)) (process-name (generate-new-buffer-name name)) (process-environment (lsp--compute-process-environment environment-fn))) (let* ((stderr-buf ...) (proc ...)) (set-process-query-on-exit-flag proc nil) (set-process-query-on-exit-flag (get-buffer-process stderr-buf) nil) (save-current-buffer (set-buffer ...) (special-mode)) (cons proc proc)))) :test\? (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ffe724c029d> :request-handlers #<hash-table equal 0/65 0x1ffe724c02bd> :response-handlers #<hash-table eql 0/65 0x1ffe724c02dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ffe709b66c1> :action-handlers #<hash-table equal 0/65 0x1ffe709da699> :major-modes nil :activation-fn (closure ((languages "perl") cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (_file-name _mode) (-contains\? languages (lsp-buffer-language))) :priority 0 :server-id perlnavigator :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 #<hash-table equal 0/65 0x1ffe709b7ec1> :download-server-fn (closure (t) (_client callback error-callback _update\?) (lsp-package-ensure 'perlnavigator callback error-callback)) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  (cons (funcall transform-fn it) it)
  (closure (... ... ... ... ... ... ... ... ... lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region ...) (it) (ignore it) (cons ... it))(#s(lsp--client :language-id nil :add-on? nil :new-connection (:connect (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (filter sentinel name environment-fn) (let ((final-command (lsp-resolve-final-function command)) (process-name (generate-new-buffer-name name)) (process-environment (lsp--compute-process-environment environment-fn))) (let* ((stderr-buf ...) (proc ...)) (set-process-query-on-exit-flag proc nil) (set-process-query-on-exit-flag (get-buffer-process stderr-buf) nil) (save-current-buffer (set-buffer ...) (special-mode)) (cons proc proc)))) :test\? (closure ((test-command) (command closure (t) nil (list (or ... ...) "--stdio")) view-inhibit-help-message cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) nil (lsp-server-present\? (lsp-resolve-final-function command)))) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ffe724c029d> :request-handlers #<hash-table equal 0/65 0x1ffe724c02bd> :response-handlers #<hash-table eql 0/65 0x1ffe724c02dd> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ffe709b66c1> :action-handlers #<hash-table equal 0/65 0x1ffe709da699> :major-modes nil :activation-fn (closure ((languages "perl") cl-struct-lsp--log-entry-tags cl-struct-lsp-session-tags cl-struct-lsp--workspace-tags cl-struct-lsp--registered-capability-tags lsp-mode-menu cl-struct-lsp--folding-range-tags cl-struct-lsp-watch-tags cl-struct-lsp--client-tags lsp--log-lines company-minimum-prefix-length dap-ui-menu-items dap-auto-configure-mode yas-also-auto-indent-first-line yas-wrap-around-region yas-indent-line yas-inhibit-overlay-modification-protection t) (_file-name _mode) (-contains\? languages (lsp-buffer-language))) :priority 0 :server-id perlnavigator :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 #<hash-table equal 0/65 0x1ffe709b7ec1> :download-server-fn (closure (t) (_client callback error-callback _update\?) (lsp-package-ensure 'perlnavigator callback error-callback)) :download-in-progress? nil :buffers nil :synchronize-sections nil))
  mapcar((closure ... ... ... ...) (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...))
  (let* ((col (mapcar #'(lambda (it) (ignore it) (cons (funcall transform-fn it) it)) collection)) (completion (completing-read prompt #'(lambda (string pred action) (if (eq action ...) '... (complete-with-action action col string pred))) predicate require-match initial-input hist def inherit-input-method))) (cdr (assoc completion col)))
  lsp--completing-read("Select server ..." (... ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (closure ... ... ...) nil t)
  (or (gethash server-id lsp-clients) (lsp--completing-read "Select server to install/re-install: " (or (-filter (-andfn (-not #'lsp--client-download-in-progress\?) #'lsp--client-download-server-fn) (ht-values lsp-clients)) (user-error "There are no servers with automatic installation")) #'(lambda (client) (let ((server-name (symbol-name ...))) (if (lsp--server-binary-present\? client) (concat server-name " (Already installed)") server-name))) nil t))
  (let* ((chosen-client (or (gethash server-id lsp-clients) (lsp--completing-read "Select server to install/re-install: " (or (-filter (-andfn ... ...) (ht-values lsp-clients)) (user-error "There are no servers with automatic installation")) #'(lambda (client) (let ... ...)) nil t))) (update\? (or update\? (and (not (progn (or ... ...) (aref chosen-client 31))) (lsp--server-binary-present\? chosen-client))))) (lsp--install-server-internal chosen-client update\?))
  lsp-install-server(nil)
  funcall-interactively(lsp-install-server nil)
  call-interactively(lsp-install-server record nil)
  command-execute(lsp-install-server record)
  execute-extended-command(nil "lsp-install-server" "lsp-install-server")
  funcall-interactively(execute-extended-command nil "lsp-install-server" "lsp-install-server")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Anything else?

No response

@BrunodaSilvaBelo
Copy link

BrunodaSilvaBelo commented Apr 24, 2022

I'm having this error too, but starting with emacs -Q and eval-buffer this minimum configuration

(defvar bootstrap-version)
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))
(straight-use-package 'lsp-mode)

I can use lsp-install-server without errors
emacs-version: GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6) of 2022-04-24

edit: with this error still is possible to install a server with M-: then run (lsp-install-server t 'SERVER_NAME) where SERVER_NAME is the name of the server you want to install

@BrunodaSilvaBelo
Copy link

I found a solution that works for me, when i set debug-on-error to nil, this error disappears and lsp-mode works normally

@thoelze1
Copy link

thoelze1 commented Dec 8, 2022

Having the same problem here on:
OS: Mac 10.15.6
Emacs: GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2021-11-18

I found that this bug was introduced by commit 82433e6 which adds PerlNavigator server support. Here is an excerpt of the backtrace after running lsp-install-server:

Debugger entered--Lisp error: (cl-assertion-failed ((seq-every-p (apply-partially #'stringp) command) "Invalid command list"))
  cl--assertion-failed((seq-every-p
                        (apply-partially #'stringp)
                        command)
                       "Invalid command list" nil nil)
  lsp-resolve-final-function(#f(compiled-function
                                ()
                                #<bytecode 0x1fe96f470ed9>))

The bytecode is:

byte code:
  args: nil
0       constant  executable-find
1       varref    lsp-perlnavigator-executable
2       call      1
3       goto-if-not-nil-else-pop 1
6       constant  lsp-package-path
7       constant  perlnavigator
8       call      1
9:1     constant  "--stdio"
10      list2     
11      return    

This code corresponds to line 187 of lsp-perlnavigator.el:

(or (executable-find lsp-perlnavigator-executable)
.

I was able to get lsp-install-server to succeed on 82433e6 by adding a dummy perlnavigator executable to my path so that (executable-find "perlnavigator") succeeded.

Similarly, I got lsp-install-server to succeed on main (e56da71) by adding an additional dummy marksman executable to my path (see

(cons (or (executable-find lsp-marksman-server-command)
).

I couldn't figure out why lsp-perlnavigator.el and lsp-marksman.el are the only two packages that need to be worked around. Any ideas?

Two last things:

  • when starting with -Q and doing a single package-install-file with lsp-mode.el off of 82433e6, I don't get an error
  • when i set debug-on-error to nil, the error is suppressed and lsp-install-server succeeds

@suvayu
Copy link
Contributor

suvayu commented Jul 23, 2023

On my machine it's lsp-credo. @thoelze1 is right about where the error is happening, but I think the analysis is a bit off. lsp-stdio-connection does a lot of the "checks" people are trying to do in their own function. e.g. for lsp-credo, this is how it looks:

(lsp-stdio-connection
(lambda ()
`(,(or (executable-find (cl-first lsp-credo-command))
(lsp-package-path 'credo-language-server))
,@(cl-rest lsp-credo-command))))

All the cl-first executable-find cl-rest business is redundant because lsp-stdio-connection already does that:

lsp-mode/lsp-mode.el

Lines 6941 to 6951 in 6ff97a3

(defun lsp-stdio-connection (command &optional test-command)
"Returns a connection property list using COMMAND.
COMMAND can be: A string, denoting the command to launch the
language server. A list of strings, denoting an executable with
its command line arguments. A function, that either returns a
string or a list of strings. In all cases, the launched language
server should send and receive messages on standard I/O.
TEST-COMMAND is a function with no arguments which returns
whether the command is present or not. When not specified
`lsp-mode' will check whether the first element of the list
returned by COMMAND is available via `executable-find'"

I replaced that with simply (lsp-stdio-connection lsp-credo-command), and called byte-compile-file on the buffer, and the issue was fixed.

@suvayu
Copy link
Contributor

suvayu commented Jul 23, 2023

If the fix above looks correct to people, I can submit a PR.

@abh1shek-sh
Copy link

abh1shek-sh commented Jul 26, 2023

I can verify @suvayu fix works for me.
How did you find out the issue was in lsp-credo.el file. From the bytecode I could only tell it's lsp-credo-command but how did you know the file and and the place ?

@suvayu
Copy link
Contributor

suvayu commented Jul 27, 2023

Well, the file was easy because since lsp-credo-command is defined in lsp-credo.el, and for the place, I don't recall exactly, but I think I noticed lsp-stdio-connection somewhere. Then I saw @thoelze1's comments. So I started experimenting interactively with lsp-stdio-connection, and looked at the source for make-lsp-client.

Since @abh1shek-sh has verified the fix works, I'll submit a PR over the weekend (including a note in the docs, since this seems to crop up).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@suvayu @BrunodaSilvaBelo @dustinpaluch @thoelze1 @abh1shek-sh and others