Closed Randy1Burrell closed 1 year ago
I get the same issue.
I have recently added a few icons in the svg format because it has a few advantages over the pngs currently in use - svgs can be upscaled without pixelation which is very useful for people with large 4k displays, they also have no trouble with overlays changing their background color, which is something I need to fix manually with png files.
For all intents and purposes svg files are the future of treemacs icons, it just will take a long time to migrate the 300 or so icons that already exist. I just hope lack for svg support is not a common issue, or at least it's easy to rectify.
Do you also see the error when you try this?
(insert (propertize " " 'display '(image :type svg :file "treemacs install dir/icons/default/vsc/dir-git-open.svg")))
What does (image-type-available-p 'svg)
return?
I get the same issue.
Are you also on a mac?
My google-fu says Emacs has supported svgs since 2007, there's 7 year old threads asking how to compile Emacs with svg support like this. Maybe you just need to install the right version?
@Alexander-Miller I am on Ubuntu 22.10 and Emacs 29 Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0)
built from Savannah source some months ago.
(insert (propertize " " 'display '(image :type svg :file "treemacs install dir/icons/default/vsc/dir-git-open.svg")))
returns nil
(image-type-available-p 'svg)
also returns nil
built from Savannah source some months ago.
I guess you missed the --with-rsvg or you don't have librsvg installed.
I evidently need to include guards against Emacs being unable to handle svg images, but that will just mean that you will not see any of the new svg icons, and eventually the old icons that will be replaced, though that will take a while.
I'm using the native packages built for Mac. What do your think the solution is here?
I'm using the native packages built for Mac. What do your think the solution is here?
You might be affected by this issue. That means you should:
Whatever plans I had to replace more icons with svgs will be shelved until Emacs 29 is out (it would not have been a priority anyway).
@Alexander-Miller It turns out I needed to build Emacs with --with-rsvg
and install librsvg2-dev. also worth noting I tried to build the latest master branch for Emacs (version 30.50) and had a load of issues (not related to treemacs) so I built off the 29.0.90
tag.
I got the same issue, add (add-to-list 'image-types 'svg)
to emacs configuration(eg: init.el) to fix it. @Randy1Burrell @chrishowejones
@xautjzd Thank you, this worked!! @ Alexander-Miller you don't need to roll back converting over to SVG since this solution works. @chrishowejones Thanks for the help, but since this work, I don't have to go through the trouble of compiling and moving away from the stable builds.
I got the same issue, add (add-to-list 'image-types 'svg) to emacs configuration(eg: init.el) to fix it.
I would have thought if an image type isn't in that list then Emacs is unable to support, but ok, whatever works :man_shrugging:.
Anyway I've prevented the creation if svg images if Emacs thinks they are not supported. I'll keep that code until Emacs 29 has been released for a while and then consider removing it and adding more svg icons.
I inadvertently built an instance of emacs 29 (tag emacs-29.0.92
) without SVG support, and I'm still seeing a similar error. The stack trace I get contains messages like:
Debugger entered--Lisp error: (error "Invalid image type ‘svg’")
error("Invalid image type `%s'" svg)
image-type(".../treemacs/icons/default/vsc/dir-src-closed.svg" svg nil)
create-image(".../treemacs/icons/default/vsc/dir-src-closed.svg" svg nil :ascent center :width 22 :height 22)
I have an easy enough way to deal with this locally (just build linking against librsvg-2
), but from what I observed, it looks like create-image
is being called from:
which is in turn called by:
when a GUI is available and some sort of image creation is possible. This is called in the treemacs-create-icon
macro, unconditionally best I can tell.
Perhaps some image support detection logic needs to be added earlier in the macro too? I can make a new issue for this if you like.
@Alexander-Miller this is an issue again it seems you were right here https://github.com/Alexander-Miller/treemacs/issues/1017#issuecomment-1520718287
Emacs now throws an error about
Debugger entered--Lisp error: (void-variable image-types)
(member 'svg image-types)
(if (member 'svg image-types) image-types (setq image-types (cons 'svg image-types)))
eval-buffer(#<buffer *load*> nil "/Users/randyburrell/.emacs.d/init.el" nil t) ; Reading at buffer position 1620
load-with-code-conversion("/Users/randyburrell/.emacs.d/init.el" "/Users/randyburrell/.emacs.d/init.el" nil nil)
load("/Users/randyburrell/.emacs.d/init.el" nil nil t)
load-file("/Users/randyburrell/.emacs.d/init.el")
(let ((debug-on-error t) (url-show-status nil) (user-emacs-directory default-directory) (user-init-file (expand-file-name "init.el")) (load-path (delq default-directory load-path))) (load-file user-init-file) (run-hooks 'after-init-hook))
eval((let ((debug-on-error t) (url-show-status nil) (user-emacs-directory default-directory) (user-init-file (expand-file-name "init.el")) (load-path (delq default-directory load-path))) (load-file user-init-file) (run-hooks 'after-init-hook)) t)
command-line-1(("--eval" "(let ((debug-on-error t)\n ..."))
command-line()
What's the problem? Recently after Emacs elpa upgraded the packages I am getting the error "Invalid image type 'svg'" from Treemacs.
Version Emacs 28.2
OS MacOS
What do you expect to happen? I expect Treemacs to work.
Debug Log