4

When I load a Dart file with GNU Emacs 27.1-1 for OS X I get the following little error novel.

Debugger entered--Lisp error: (void-function -compose)
(-compose #'lsp--client-path->uri-fn #'lsp--workspace-client)
(-keep (-compose #'lsp--client-path->uri-fn #'lsp--workspace-client) (lsp-workspaces))
(cl-first (-keep (-compose #'lsp--client-path->uri-fn #'lsp--workspace-client) (lsp-workspaces)))
(and t (cl-first (-keep (-compose #'lsp--client-path->uri-fn #'lsp--workspace-client) (lsp-workspaces))))
(let* ((uri-fn (and t (cl-first (-keep (-compose #'lsp--client-path->uri-fn #'lsp--workspace-client) (lsp-workspaces)))))) (if uri-fn (funcall uri-fn path) (lsp--path-to-uri-1 path)))
lsp--path-to-uri("/Users/sam/.emacs.d/index.sqlite")
(closure (t) nil (lsp--path-to-uri (f-join user-emacs-directory "index.sqlite")))()
funcall((closure (t) nil (lsp--path-to-uri (f-join user-emacs-directory "index.sqlite"))))
eval((funcall #'(closure (t) nil (lsp--path-to-uri (f-join user-emacs-directory "index.sqlite")))))
custom-initialize-reset(lsp-serenata-index-database-uri (funcall #'(closure (t) nil (lsp--path-to-uri (f-join user-emacs-directory "index.sqlite")))))
custom-declare-variable(lsp-serenata-index-database-uri (funcall #'(closure (t) nil (lsp--path-to-uri (f-join user-emacs-directory "index.sqlite")))) "The location to store the index database.\nNote tha..." :group lsp-serenata :type file)
eval-buffer(#<buffer  *load*> nil "/Users/sam/.emacs.d/elpa/lsp-mode-20210222.1457/lsp..." nil t)  ; Reading at buffer position 12399
load-with-code-conversion("/Users/sam/.emacs.d/elpa/lsp-mode-20210222.1457/lsp..." "/Users/sam/.emacs.d/elpa/lsp-mode-20210222.1457/lsp..." t t)
require(lsp-php nil t)
(if (featurep package) nil (require package nil t))
(closure (company-mode 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 dap-ui-menu-items company-backends t) (package) (if (featurep package) nil (require package nil t)))(lsp-php)
mapc((closure (company-mode 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 dap-ui-menu-items company-backends t) (package) (if (featurep package) nil (require package nil t))) (ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-dart lsp-dhall lsp-dockerfile lsp-elm lsp-elixir lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-hack lsp-groovy lsp-haskell lsp-haxe lsp-java lsp-javascript lsp-json lsp-kotlin lsp-lua lsp-nim lsp-nix lsp-metals lsp-ocaml lsp-perl lsp-php lsp-pwsh lsp-pyls lsp-python-ms lsp-purescript lsp-r lsp-rf lsp-rust lsp-solargraph lsp-sorbet lsp-tex lsp-terraform lsp-vala lsp-verilog ...))
seq-do((closure (company-mode 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 dap-ui-menu-items company-backends t) (package) (if (featurep package) nil (require package nil t))) (ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-dart lsp-dhall lsp-dockerfile lsp-elm lsp-elixir lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-hack lsp-groovy lsp-haskell lsp-haxe lsp-java lsp-javascript lsp-json lsp-kotlin lsp-lua lsp-nim lsp-nix lsp-metals lsp-ocaml lsp-perl lsp-php lsp-pwsh lsp-pyls lsp-python-ms lsp-purescript lsp-r lsp-rf lsp-rust lsp-solargraph lsp-sorbet lsp-tex lsp-terraform lsp-vala lsp-verilog ...))
(progn (seq-do #'(lambda (package) (if (featurep package) nil (require package nil t))) lsp-client-packages) (setq lsp--client-packages-required t))
(if (and lsp-auto-configure (not lsp--client-packages-required)) (progn (seq-do #'(lambda (package) (if (featurep package) nil (require package nil t))) lsp-client-packages) (setq lsp--client-packages-required t)))
lsp--require-packages()
lsp()
run-hooks(change-major-mode-after-body-hook prog-mode-hook dart-mode-hook)
apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook dart-mode-hook))
run-mode-hooks(dart-mode-hook)
dart-mode()
set-auto-mode-0(dart-mode nil)
set-auto-mode()
normal-mode(t)
after-find-file(nil t)
find-file-noselect-1(#<buffer main.dart> "~/sam/flutter/proj9/lib/main.dart" nil nil "~/sam/flutter/proj9/lib/main.dart" (15751399 16777223))
find-file-noselect("/Users/sam/flutter/proj9/lib/mai..." nil nil nil)
find-file("/Users/sam/flutter/proj9/lib/mai...")
dired-find-file()
funcall-interactively(dired-find-file)
call-interactively(dired-find-file nil nil)
command-execute(dired-find-file)

How do I solve Lisp error: (void-function -compose) when using lsp-dart?

Basil
  • 12,019
  • 43
  • 69
Sam
  • 317
  • 1
  • 11
  • The immediate cause of the error is that emacs does not know how to define `-compose`. Try `(require 'dash-functional)` to fix this? – Fran Burstall Feb 27 '21 at 11:23
  • @FranBurstall Do you mean this one: https://github.com/magnars/dash.el/blob/master/dash-functional.el ? But it doesn't show a `-compose` option. In any case, after this additional require, the same error remains. – Sam Feb 27 '21 at 14:13
  • 1
    Does `(require 'dash)` help? It looks like maybe your dash installation is broken, or maybe too old for your lsp-mode install? Try upgrading your dash package? – Croad Langshan Feb 27 '21 at 15:39
  • 1
    @CroadLangshan You're right. That solves it. Yet a reliance on dash is not mentioned (https://emacs-lsp.github.io/lsp-dart/). – Sam Feb 27 '21 at 21:57
  • Now a different kind of problem ("Server dart_analysis_server:54475/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)") is persistent, and stderr isn't visible, not even with `debug-on-error` set to t. – Sam Feb 27 '21 at 22:01
  • Can you help others who might come here with a similar problem by indicating what solved it? Was it upgrading dash? If it breaks a different way now you should probably search for / ask a different question, but: as the message you posted indicates, I think you should have a buffer `*dart-ls::stderr*` – Croad Langshan Feb 28 '21 at 09:51
  • @CroadLangshan You're right. I do have a buffer *dart_analysis_server::stderr*, which says `Could not find a command named "/usr/local/flutter/bin/snapshots/analysis_server.dart.snapshot".` `Usage: dart [] []`. (`/usr/local/flutter` is where I install Flutter.) Let me try a bit to see what this is about on my side. – Sam Feb 28 '21 at 19:17
  • @FranBurstall `dash-functional` no longer provides `-compose`, and is now deprecated as a package. All of its definitions, including `-compose`, were moved to `dash` version `2.18.0`. See https://github.com/magnars/dash.el/blob/master/NEWS.md#from-217-to-218 – Basil Feb 28 '21 at 21:34
  • @CroadLangshan Oddly, analysis_server.dart started working after I _downgraded_ to Gnu Emacs 27.1-1 (from the draft of a future Emacs 28)—and, I believe, with no other changes. I also now see the multi-line parenthesis matching within Dart code in all its glory. Who knew that Emacs had these possibilities all along! – Sam Mar 02 '21 at 18:03
  • @Sam OMG, thank you for this. I had the same issue with LSP for Rust in Emacs. I read the instructions here: https://robert.kra.hn/posts/2021-02-07_rust-with-emacs/. And the `dash` requirement is not mentioned anywhere. – user4035 Mar 14 '21 at 22:00

1 Answers1

4

By chance, after commenting on this, hours later I ran into exactly the same issue. The cause was that spacemacs had for a while pinned its version of dash at 2.17.0, and -compose was introduced in 2.18.0 (moved over from the now obsolete package dash-functional). The latest lsp-mode.el uses that function.

I fixed it by updating my spacemacs checkout to the latest on branch develop.

I suspect the issue was fixed for me by https://github.com/syl20bnr/spacemacs/commit/ae65f3cedd7328b7f346f01e4597979671d67f5a

Basil
  • 12,019
  • 43
  • 69
Croad Langshan
  • 3,192
  • 14
  • 42
  • Bingo. I was using the latest official release, `Emacs-27.1-1-universal.dmg` from `https://emacsformacosx.com/builds`. As suggested, I was able to make this work by manually downloading `dash-20210210.1449`. Note that adding `(require 'dash)` is _not_ necessary. (Is that because Emacs internally requires dash _and_ it somehow grabs the latest version??) After I downloaded and used the bleeding-edge release `Emacs-2020-12-29_01-40-19-ee0e259…-universal.dmg` (GNU Emacs 28.0.50) I no longer need to have `dash-20210210.1449` in my `elpa` folder. – Sam Feb 28 '21 at 19:07
  • To make a long story short: either download the bleeding-edge, not-yet-released Emacs when you upgrade `lsp-dart`, or upgrade `dash` manually. – Sam Feb 28 '21 at 19:08
  • Getting "Server dart_analysis_server:54475/starting exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n)" is a separate issue. – Sam Feb 28 '21 at 19:09
  • 1
    @Croad Langshan For a long time, `-compose` was provided by the `dash-functional` package, which was separate from `dash` due to its dependence on `lexical-binding`. Now that `dash` requires `lexical-binding` too, the two packages were merged, and so `dash 2.18.0` is the first version of `dash` to include all the functions previously provided by `dash-functional`. See https://github.com/magnars/dash.el/blob/master/NEWS.md#from-217-to-218 – Basil Feb 28 '21 at 21:29
  • @Sam Emacs has never and probably will never include or internally require `dash`, as it is an external package officially distributed via [GNU ELPA](https://elpa.gnu.org/packages/dash.html) and [GNU-devel ELPA](https://elpa.gnu.org/devel/dash.html). As long as you have Emacs 24+, it shouldn't matter what Emacs version you're using; `dash` will work the same. – Basil Feb 28 '21 at 21:30
  • I have thee same error in normal emacs with lsp-mode. LSP is trying to open lsp--path-to-uri("/home/jenia/.emacs.d/index.sqlite") Who was supposed to create that DB? – Jenia Ivanov Apr 07 '21 at 02:20
  • I had this same message because I had 2 versions of dash: one in elpa folder, the other one in el-get. I removed the el-get version and that solved the problem. – Raoul HATTERER Jun 13 '21 at 01:29