20

since upgrading to macOS Ventura, my Emacs 28.2 installation throws the error message image-type: Invalid image type ‘svg’ at the startup of Emacs.

M-: (image-type-available-p 'svg) RET returns t.

Might someone know why this error occurs and how to resolve it? \

EDIT: In answer to a comment, the value of image-types is (png gif tiff jpeg xpm xbm pbm) - note that svg is not a member of that list.

Also, the value of image-use-external-converter is nil.

I just installed version 28.2 of Emacs (released 2022-09-12) from here on Ventura 13.0.1.

Unfortunately, I upgraded to Ventura prematurely. Now both emacs and Google Drive no longer works. I'm hoping to find a solution to both problems or to downgrade to the previous version of MacOS Monterey 12.x. I'm hoping to get some help on these issues. I do not have enough reputation points on this site yet.

4
  • I am stumped by exactly the same problem. My emacs is from emacsformacosx.com: GNU Emacs 28.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2022-09-12 Could it be specific to this version?
    – Heikki
    Nov 8, 2022 at 6:53
  • Same for me. I installed emacs homebrew cask on new machine, just after upgrade to Ventura. I don't have the same problem on my work Monterey machine.
    – Kevin N
    Nov 9, 2022 at 17:12
  • Do C-h v image-types - does it include svg? Also do C-h v image-use-external-converter - what is its value?
    – NickD
    Nov 9, 2022 at 23:33
  • Does this occur if you start with emacs -Q? If not, search your init file for image-type. If you don't find anything, try emacs --debug-init and see if you get a backtrace. If you do, edit your question and add it.
    – NickD
    Nov 9, 2022 at 23:37

4 Answers 4

14

This is an issue with the way Emacs initializes its image support on macOS Ventura. It's fixed on the current master branch, and will be in Emacs 29 when that is released.

See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59081

5
  • Can you provide a link to the bug report/fix?
    – NickD
    Nov 13, 2022 at 6:07
  • 1
    @NickD done (although the commit doesn't have a bug# in it, <sigh>)
    – rpluim
    Nov 14, 2022 at 10:06
  • There is a reply to the bug report mentioning a couple of commits. So if somebody is determined enough, they can find their way to a fix, although admittedly they would have to know their way around git to do so. Maybe the fix can be backported to Emacs 28?
    – NickD
    Nov 14, 2022 at 13:08
  • 1
    There are no more releases of emacs-28 planned: the start of the release stabilization for emacs-29 is imminent. But if you can pin down exactly which commits are needed you can try to convince Eli
    – rpluim
    Nov 14, 2022 at 13:59
  • The bug number is in the link (59081), but it's not needed. The information in the report is sufficient to solve the problem, this did it for me: git clone https://github.com/emacs-mirror/emacs.git cd emacs git checkout -b svg-fix-28.2 emacs-28.2 git cherry-pick 5f8c655a44a0e7ad1fe6f8b23acb4e6c93dc72a6 44138d5ecce275caef9efe0ae4f4a89e4a33b588 ./autogen.sh make ./src/emacs Detailed information are in the INSTALL file. (I don't have reputation enough to answer the question properly though.) Apr 11, 2023 at 16:40
11

I tried a little workaround to see if it works - overriding image-type-available-p like this:

;; overriding image.el function image-type-available-p
(defun image-type-available-p (type)
  "Return t if image type TYPE is available.
Image types are symbols like `xbm' or `jpeg'."
  (if (eq 'svg type)
      nil
    (and (fboundp 'init-image-library)
         (init-image-library type))))

This seems to make elfeed and eww work without throwing errors.

Hope it helps things work for you until there Emacs 29 is released.

1
  • 10
    That didn't work for me but after a bit of research into the cause I added (add-to-list 'image-types 'svg) to my Emacs config and now everything is working.
    – artran
    Apr 17, 2023 at 10:07
9

This seems to only happen when you have an .emacs file. I too just installed Emacs with brew install --cask emacs and it was working fine until I added an .emacs file. (I compulsively disable tool-bar-mode for all eternity before I puke.)

Based on other answers here, adding this brief stanza to the beginning of my .emacs allowed Emacs to work without the warning again.

(setq image-types (cons 'svg image-types))

This is basically the same as George Mauer's answer except it uses the previous value of image-types and prepends svg in front, rather than hard-coding the entire list.

1
  • This works for the emacsformacosx.com version, which is still 28.2 in 2023/07
    – Marvin
    Jul 13, 2023 at 12:56
2

I'm not 100% clear what other impacts it has. You can see the error comes from this code:

  (when (and (not (eq type 'image-convert))
             (not (memq type (and (boundp 'image-types) image-types))))

Simply adding svg to the image-types list fixed it for me.

(setq image-types '(svg png gif tiff jpeg xpm xbm pbm))

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