emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.75k stars 873 forks source link

Get "Invalid Image type: 'svg' when I trying to run lsp-mode #4054

Open idhowardgj94 opened 1 year ago

idhowardgj94 commented 1 year ago

Thank you for the bug report

Bug description

I follow the installation guide except I use straight as package manager.

everything work smooth , untill when I want to open lsp-mode via M-x lsp-mode or install a new language server via ~M-x lsp-install-serverit give meInvalid Image type: svg.`

Steps to reproduce

my lsp-mode related init file

;;; -*- lexical-binding: t -*-

(use-package lsp-mode
  :straight t 
  :init
  ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
  (setq lsp-keymap-prefix "C-c l")
  :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
         ;; (XXX-mode . lsp-deferred)
         ;; if you want which-key integration
         (lsp-mode))
  :commands (lsp))

;; optionally
(use-package lsp-ui
  :straight t
  :commands lsp-ui-mode)
;; if you are helm user
(use-package helm-lsp
  :straight t
  :commands helm-lsp-workspace-symbol)
;; if you are ivy user
(use-package lsp-ivy
  :straight t
  :commands lsp-ivy-workspace-symbol)
(use-package lsp-treemacs 
             :straight t
             :commands lsp-treemacs-errors-list)

;; optionally if you want to use debugger
(use-package dap-mode
   )
;; (use-package dap-LANGUAGE) to load the dap adapter for your language
(use-package which-key
  :straight t
  :config
    (which-key-mode))
(provide 'init-lsp)

Expected behavior

work as normal.

Which Language Server did you use?

javascript

OS

Linux

Error callstack

Debugger entered--Lisp error: (error "Invalid image type ‘svg’")
  signal(error ("Invalid image type ‘svg’"))
  error("Invalid image type `%s'" svg)
  image-type("/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/ico..." svg nil)
  create-image("/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/ico..." svg nil :ascent center :width 22 :height 22)
  (if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern (if (string-match treemacs-file-extension-regex icon-path) (substring icon-path (1+ (match-beginning 0))) icon-path)) nil :ascent 'center :width width :height height))
  (let ((height treemacs--icon-size) (width treemacs--icon-size)) (if (and (integerp treemacs--icon-size) (s-starts-with\? "root-" icon-path)) (progn (let ((w (round (* width 0.909))) (h (round (* height 1.1818)))) (setq width w height h)))) (if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern (if (string-match treemacs-file-extension-regex icon-path) (substring icon-path (1+ (match-beginning 0))) icon-path)) nil :ascent 'center :width width :height height)))
  (let* ((img-selected (let ((height treemacs--icon-size) (width treemacs--icon-size)) (if (and (integerp treemacs--icon-size) (s-starts-with\? "root-" icon-path)) (progn (let (... ...) (setq width w height h)))) (if (and (integerp treemacs--icon-size) (image-type-available-p 'imagemagick)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern (if ... ... icon-path)) nil :ascent 'center :width width :height height)))) (img-unselected (copy-sequence img-selected))) (nconc img-selected '(:background "darkseagreen2")) (nconc img-unselected '(:background "white")) (concat (propertize " " 'display img-unselected 'img-selected img-selected 'img-unselected img-unselected) " "))
  (if (not (image-type-available-p 'png)) fallback (let* ((img-selected (let ((height treemacs--icon-size) (width treemacs--icon-size)) (if (and (integerp treemacs--icon-size) (s-starts-with\? "root-" icon-path)) (progn (let ... ...))) (if (and (integerp treemacs--icon-size) (image-type-available-p ...)) (create-image icon-path 'imagemagick nil :ascent 'center :width width :height height) (create-image icon-path (intern ...) nil :ascent 'center :width width :height height)))) (img-unselected (copy-sequence img-selected))) (nconc img-selected '(:background "darkseagreen2")) (nconc img-unselected '(:background "white")) (concat (propertize " " 'display img-unselected 'img-selected img-selected 'img-unselected img-unselected) " ")))
  (let ((tui-icon fallback) (gui-icon (if (not (image-type-available-p 'png)) fallback (let* ((img-selected (let ... ... ...)) (img-unselected (copy-sequence img-selected))) (nconc img-selected '(:background "darkseagreen2")) (nconc img-unselected '(:background "white")) (concat (propertize " " 'display img-unselected 'img-selected img-selected 'img-unselected img-unselected) " "))))) (cons gui-icon tui-icon))
  (let* ((xs (mapcar #'(lambda (it) (ignore it) (if (stringp it) (downcase it) it)) '("src-closed"))) (fallback (propertize "+ " 'face 'treemacs-term-node-face)) (icons-dir (progn (or (progn (and (memq ... cl-struct-treemacs-theme-tags) t)) (signal 'wrong-type-argument (list 'treemacs-theme treemacs--current-theme))) (aref treemacs--current-theme 2))) (icon-path (treemacs-join-path icons-dir "vsc/dir-src-closed.svg")) (icon-pair (let ((tui-icon fallback) (gui-icon (if (not ...) fallback (let* ... ... ... ...)))) (cons gui-icon tui-icon))) (gui-icons (progn (or (progn (and (memq ... cl-struct-treemacs-theme-tags) t)) (signal 'wrong-type-argument (list 'treemacs-theme treemacs--current-theme))) (aref treemacs--current-theme 3))) (tui-icons (progn (or (progn (and (memq ... cl-struct-treemacs-theme-tags) t)) (signal 'wrong-type-argument (list 'treemacs-theme treemacs--current-theme))) (aref treemacs--current-theme 4))) (gui-icon (car icon-pair)) (tui-icon (cdr icon-pair))) nil (if (get-text-property 0 'display gui-icon) nil (setq gui-icon (propertize " " 'display gui-icon))) (let ((--dolist-tail-- xs)) (while --dolist-tail-- (let ((ext (car --dolist-tail--))) (if (symbolp ext) (progn (let* (...) (add-to-list ... ext) (set symbol nil)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (let ((list xs) (i 0)) (while list (let ((it (car-safe (prog1 list ...))) (it-index i)) (ignore it it-index) (if (and (not (image-type-available-p ...)) (string= (if ... ... "vsc/dir-src-closed.svg") "svg")) nil (prog1 nil (puthash it gui-icon gui-icons))) (prog1 nil (puthash it tui-icon tui-icons))) (setq i (1+ i)))))
  (progn (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) (let* ... nil ... ... ...) ...)
  (let* (...) (progn ... ... ... ... ... ... ... ... ... ... ... ... ... ...) (treemacs--propagate-new-icons theme))
  (let* (... ... ...) (add-to-list ... theme) nil (let* ... ... ...) "Default")
  eval-buffer(#<buffer  *load*-855501> nil "/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/tre..." nil t)  ; Reading at buffer position 32410
  load-with-code-conversion("/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/tre..." "/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/tre..." nil t)
  require(treemacs-icons)
  eval-buffer(#<buffer  *load*-156601> nil "/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/tre..." nil t)  ; Reading at buffer position 1294
  load-with-code-conversion("/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/tre..." "/tmp/lsp-tmp-elpaJbSV4a/treemacs-20230510.1644/tre..." nil t)
  require(treemacs)
  eval-buffer(#<buffer  *load*-608501> nil "/tmp/lsp-tmp-elpaJbSV4a/lsp-treemacs-20230504.516/..." nil t)  ; Reading at buffer position 1073
  load-with-code-conversion("/tmp/lsp-tmp-elpaJbSV4a/lsp-treemacs-20230504.516/..." "/tmp/lsp-tmp-elpaJbSV4a/lsp-treemacs-20230504.516/..." nil t)
  require(lsp-treemacs)
  eval-buffer(#<buffer  *load*-274268> nil "/tmp/lsp-tmp-elpaJbSV4a/lsp-java-20230507.517/lsp-..." nil t)  ; Reading at buffer position 1136
  load-with-code-conversion("/tmp/lsp-tmp-elpaJbSV4a/lsp-java-20230507.517/lsp-..." "/tmp/lsp-tmp-elpaJbSV4a/lsp-java-20230507.517/lsp-..." nil t)
  require(lsp-java)
  (closure ((pkg-list lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode) t) (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg))(lsp-java)
  mapc((closure ((pkg-list lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode) t) (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg)) (lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode))
  (let* ((pkg-list '(lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode haskell-mode))) (package-initialize) (package-refresh-contents) (mapc #'(lambda (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg)) pkg-list) (yas-global-mode) (add-hook 'prog-mode-hook 'lsp) (add-hook 'kill-emacs-hook (list 'lambda nil (cons 'delete-directory (cons package-user-dir '(t))))))
  eval-buffer(#<buffer  *load*> nil "/tmp/plainITCgcM.el" nil t)  ; Reading at buffer position 2311
  load-with-code-conversion("/tmp/plainITCgcM.el" "/tmp/plainITCgcM.el" nil t)
  load("/tmp/plainITCgcM.el" nil t)
  command-line-1(("-l" "/tmp/plainITCgcM.el" "/home/howard/workspace/emacs_dot_d/index.js"))
  command-line()
  normal-top-level()

Anything else?

No response

idhowardgj94 commented 1 year ago

when I delete lsp-treemacs related use-package, the error gone. maybe it's some error related to lsp-treemacs

whompyjaw commented 1 year ago

I get this same error after reinstalling my doom emacs today. Occured on clang and pyright/pylsp language servers. I don't think it has anything to with the LSP's.

I have been trying to disable whatever command I can to disable lsp-treemacs and treemacs in my config, but it doesn't seem to work. And google/gpt don't tell me how to completely disable treemacs.

yyoncho commented 1 year ago

In general, the issue is caused by emacs build not supporting svg. We should handle it a bit more gracefully, but if you have the option just go and install a version supporting svg images.

whompyjaw commented 1 year ago

@yyoncho, thanks for quick reply. Unfortunately, I don't. I am using my work's emacs version. I could compile from source, but my remote station doesn't have the dependencies for emacs 28.1. At least idk where they are to put them in my LD path. Interestingly, this error wasn't occurring before with the same emacs version. So it seems like something changed in one of the packages. As much as I love lsp-mode, I had to switch to eglot because nothing I tried would disable the error. I wish it were a bit easier to disable lsp-treemacs or treemacs in lsp-mode.

idhowardgj94 commented 1 year ago

@saltsucker FYI, I use straight.el to manage my package, it won't load package if you comment out the package you don't want to load. So I just comment out tree macs related in my init.el, then error gone.

But I compile eMacs which support svg by now.

It's turn out that emacs version of gnu emacs seems to have other problems, so I think maybe downgrade treemacs version should work. But I haven't dig into this yet.

idhowardgj94 commented 1 year ago

Sorry, It's seems a mistake. I install a version without svg support, and this error occur even if I rm all treemacs related package.

idhowardgj94 commented 1 year ago

ok find out that dap-mode may use treemacs, which cause the error disable dap-mode and error gone.

whompyjaw commented 1 year ago

@saltsucker FYI, I use straight.el to manage my package, it won't load package if you comment out the package you don't want to load. So I just comment out tree macs related in my init.el, then error gone.

But I compile eMacs which support svg by now.

It's turn out that emacs version of gnu emacs seems to have other problems, so I think maybe downgrade treemacs version should work. But I haven't dig into this yet.

ok find out that dap-mode may use treemacs, which cause the error disable dap-mode and error gone.

Yes, I use doom and you can easily not install it by commenting it out in the init.el. That's a good catch with the dap-mode. I forgot that is related to lsp.

kmgolden commented 1 year ago

Confirming that I have the same error with latest 28.2 build of Emacs from the https://emacsformacosx.com/ package, which is built with librsvg. Error seems to trace to treemacs

kmgolden commented 1 year ago

Found the workaround: https://github.com/Alexander-Miller/treemacs/issues/1017#issuecomment-1515602288

; add below line to init.el
(add-to-list 'image-types 'svg)

@idhowardgj94

idhowardgj94 commented 1 year ago

@kmgolden many thx, you save my day... days

reutsharabani commented 1 year ago

@kmgolden worked for me. Thanks!

8dcc commented 11 months ago

In my case, png wasn't in my image-types list. What could cause this?


EDIT: After looking at the GNU emacs manual, I saw that it required libpng to be installed. This did not fix the issue.