1

My current emacs version is 27.2, OS is Ubuntu 20.04,Java version is 11.0.11.

I was following the official guide of installing metals on emacs, did a little change from the course at the start (I first installed required packages/dependencies through M-x package-list-packages and only then did what was going on on the guide, but from my understanding, it shouldn't matter. My current init.el file contains the code related to lsp-mode:

;; Install use-package if not already installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

(require 'use-package)

;; Enable defer and ensure by default for use-package
;; Keep auto-save/backup files separate from source code:  https://github.com/scalameta/metals/issues/1027
(setq use-package-always-defer t
      use-package-always-ensure t
      backup-directory-alist `((".*" . ,temporary-file-directory))
      auto-save-file-name-transforms `((".*" ,temporary-file-directory t)))

;; Enable scala-mode for highlighting, indentation and motion commands
(use-package scala-mode
  :interpreter
    ("scala" . scala-mode))

;; Enable sbt mode for executing sbt commands
(use-package sbt-mode
  :commands sbt-start sbt-command
  :config
  ;; WORKAROUND: https://github.com/ensime/emacs-sbt-mode/issues/31
  ;; allows using SPACE when in the minibuffer
  (substitute-key-definition
   'minibuffer-complete-word
   'self-insert-command
   minibuffer-local-completion-map)
   ;; sbt-supershell kills sbt-mode:  https://github.com/hvesalai/emacs-sbt-mode/issues/152
   (setq sbt:program-options '("-Dsbt.supershell=false"))
)

;; Enable nice rendering of diagnostics like compile errors.
(use-package flycheck
  :init (global-flycheck-mode))

(use-package lsp-mode
  ;; Optional - enable lsp-mode automatically in scala files
  :hook  (scala-mode . lsp)
         (lsp-mode . lsp-lens-mode)
  :config
  ;; Uncomment following section if you would like to tune lsp-mode performance according to
  ;; https://emacs-lsp.github.io/lsp-mode/page/performance/
  ;;       (setq gc-cons-threshold 100000000) ;; 100mb
  ;;       (setq read-process-output-max (* 1024 1024)) ;; 1mb
  ;;       (setq lsp-idle-delay 0.500)
  ;;       (setq lsp-log-io nil)
  ;;       (setq lsp-completion-provider :capf)
  (setq lsp-prefer-flymake nil))

;; Add metals backend for lsp-mode
(use-package lsp-metals)

;; Enable nice rendering of documentation on hover
;;   Warning: on some systems this package can reduce your emacs responsiveness significally.
;;   (See: https://emacs-lsp.github.io/lsp-mode/page/performance/)
;;   In that case you have to not only disable this but also remove from the packages since
;;   lsp-mode can activate it automatically.
(use-package lsp-ui)

;; lsp-mode supports snippets, but in order for them to work you need to use yasnippet
;; If you don't want to use snippets set lsp-enable-snippet to nil in your lsp-mode settings
;;   to avoid odd behavior with snippets and indentation
(use-package yasnippet)

;; Use company-capf as a completion provider.
;;
;; To Company-lsp users:
;;   Company-lsp is no longer maintained and has been removed from MELPA.
;;   Please migrate to company-capf.
(use-package company
  :hook (scala-mode . company-mode)
  :config
  (setq lsp-completion-provider :capf))

;; Use the Debug Adapter Protocol for running tests and debugging
(use-package posframe
  ;; Posframe is a pop-up tool that must be manually installed for dap-mode
  )
(use-package dap-mode
  :hook
  (lsp-mode . dap-mode)
  (lsp-mode . dap-ui-mode)
  )

without the first part of adding melpa, since I got it added already. After doing everything and restarting the Emacs, I proceeded with opening .scala file and on open I get a debug message:

Debugger entered--Lisp error: (void-function -compose)                                                                                                                                                     
  -compose(lsp--client-path->uri-fn lsp--workspace-client)                                                                                                                                                 
  lsp--path-to-uri("pathtoemacs/.emacs.d/index.sqlite")                                                                                                                                            
  #f(compiled-function () #<bytecode 0x15566aea7e91>)()                                                                                                                                                    
  funcall(#f(compiled-function () #<bytecode 0x15566aea7e91>))                                                                                                                                             
  eval((funcall #'#f(compiled-function () #<bytecode 0x15566aea7e91>)))                                                                                                                                    
  custom-initialize-reset(lsp-serenata-index-database-uri (funcall #'#f(compiled-function () #<bytecode 0x15566aea7e91>)))                                                                                 
  custom-declare-variable(lsp-serenata-index-database-uri (funcall #'#f(compiled-function () #<bytecode 0x15566aea7e91>)) "The location to store the index database.\nNote tha..." :group lsp-serenata :ty$
  byte-code("\301\302\303\304 \305\306\307!\310\311\312\313&\10!\210\314\315\316\317\320\321\322\323\324\325&\11\210\326\327\330\331\332DD\333\334\335\320\315\324\336&\11\210\326\337\330..." [lsp-intele$
  require(lsp-php nil t)                                                                                                                                                                                   
  #f(compiled-function (package) #<bytecode 0x15566ad2cc81>)(lsp-php)                                                                                                                                      
  mapc(#f(compiled-function (package) #<bytecode 0x15566ad2cc81>) (ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-d $
  seq-do(#f(compiled-function (package) #<bytecode 0x15566ad2cc81>) (ccls lsp-actionscript lsp-ada lsp-angular lsp-bash lsp-beancount lsp-clangd lsp-clojure lsp-cmake lsp-crystal lsp-csharp lsp-css lsp-$
  lsp--require-packages()                                                                                                                                                                                  
  lsp()                                                                                                                                                                                                    
  run-hooks(change-major-mode-after-body-hook prog-mode-hook scala-mode-hook)                                                                                                                              
  apply(run-hooks (change-major-mode-after-body-hook prog-mode-hook scala-mode-hook))                                                                                                                      
  run-mode-hooks(scala-mode-hook)                                                                                                                                                                          
  scala-mode()                                                                                                                                                                                             
  set-auto-mode-0(scala-mode nil)                                                                                                                                                                          
  set-auto-mode()                                                                                                                                                                                          
  normal-mode(t)                                                                                                                                                                                           
  after-find-file(nil t)                                                                                                                                                                                   
  find-file-noselect-1(#<buffer test.scala> "~/Scala/test.scala" nil nil "~/Python_rofli/Scala/test.scala" (5288230 2065))                                                                    
  find-file-noselect("~/Scala/test.scala" nil nil)                                                                                                                          
  ido-file-internal(raise-frame)                                                                                                                                                                           
  ido-find-file()                                                                                                                                                                                          
  funcall-interactively(ido-find-file)                                                                                                                                                                     
  call-interactively(ido-find-file nil nil)                                                                                                                                                                
  command-execute(ido-find-file)   

I can try to open the .scala file again and it will be opened, but upon trying to activate lsp-mode, it will tell [Disabled] and a bunch of other errors about not having a connection to the server. And according to the debug message, I am supposed to have some kind of index.sqlite inside my .emacs.d folder, but I don't have one, and creating one didn't help. I also followed the alternative LSP server listed there, the "Eglot", and it worked fine, but upon switching back to lsp-mode variant, it was still giving the same error. Any idea how to start debugging this mess? I tried to manually install metals, tried shenanigans with a "coursier", nothing helped.

1 Answer 1

0

Got a response on emacs-metals GitHub on how to fix that issue. The solution is to update/install a dash package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.