Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Invalid image type ‘xpm’ on systems without X server installed #53

Open
slapierre opened this Issue Sep 25, 2017 · 14 comments

Comments

Projects
None yet
4 participants

slapierre commented Sep 25, 2017 edited

When loading treemacs on a server where X is not installed, I get an "invalid image type" error that prevents treemacs from loading.

The "icon fallback" mentionned in this Reddit conversation works fine on Windows and "GUI Linux" when I start Emacs with the "-nw" option, however the issue I am facing occurs on CentOs boxes that don't have X installed and where I had to build Emacs with "--without-x", "--with-png=no", etc.

Here are the two errors I get, to get passed the first xpm error I tweaked the code a little bit and replaced create-image by a concat in the 3 defconst (treemacs-icon-tag-leaf, treemacs-icon-tag-node-closed and treemacs-icon-tag-node-open) in treemacs-tags.el:

1. image-type: Invalid image type ‘xpm’ -- occurs when treemacs-icon-tag-leaf is evaluated
2. image-type: Invalid image type ‘png’ -- occurs (I think) when treemacs--create-icons is evaluated 

Here is the value of window-system variable:

(describe-variable 'window-system)
;; Its value is nil

Here is how I built Emacs, it has a dependency on ncurse:

##
## Emacs
##

# Dependency
tar -zxvf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=$HOME/usr/local
make
make install  

# Emacs
tar -zxvf emacs-25.1.tar.gz
cd emacs-25.1
export LDFLAGS=-L$HOME/usr/local/lib/
./configure --prefix=$HOME/usr/local --without-all --without-x --with-x-toolkit=no --with-xpm=no --with-jpeg=no --with-png=no --with-gif=no --with-tiff=no
make
make install
Owner

Alexander-Miller commented Sep 25, 2017

Here is the value of window-system variable:

I didn't mean the variable's value. It's a function that's supposed to tell me what kind of display you're running in, so you just call it once, it does not matter where.

Of course looking at it's doc string I am using it wrong anyway. What's the output of (display-graphic-p) for you?

slapierre commented Sep 25, 2017 edited

I don't think you are using window-system in the wrong way . I get nil in both cases for CentOs:

System Value of window-system value of display-graphic-p
Xubuntu at home (with X) x t
CentOs (No X) nil nil
Windows 10 w32 t

Edit: This is interesting: I also get a "nil" / "nil" when I emacs -nw on my Xubuntu.

I'm seeing this error as well. I'm running emacs -nw on macOS, installed via brew install emacs.

(window-system) and (display-graphic-p) both return nil.

Owner

Alexander-Miller commented Sep 26, 2017

Ah, I think I know what's going on. It's not about the simple icon fallback, since your emacs doesnt have support for creating images treemacs is not even loaded properly since it runs into errors when creating icons when it's first loading.

I need to create a means to disable the creation of icons at load time, and force the simple fallback. I'll get back to you when I've come up with something.

agsdot commented Sep 27, 2017

👍 Looking forward to this issue getting solved too.

slapierre commented Sep 27, 2017 edited

Hi @Alexander-Miller,

It is my understanding as well that you'd need to add a couple of when at strategic places across the code to prevent calling functions that load images, I tried to do this but I did not have sufficient insights to know what was okay to "disable" -- so I ended up with a weird behavior ;)

Owner

Alexander-Miller commented Sep 27, 2017

Pretty much, yes. Catch it early enough, and disable all the parts that create and use image icons.

I've tried doing just that, and it's going well. Now I need to make sure treemacs can actually detect the lack of a graphical environment. AFAIK I don't have the means the test this myself, so I need your help here: What happens when you run (create-image "" 'xpm)?

@Alexander-Miller I get the following error:

~ (create-image "" 'xpm)
Invalid image type ‘xpm’

Backtrace:

Debugger entered--Lisp error: (error "Invalid image type ‘xpm’")
  signal(error ("Invalid image type ‘xpm’"))
  error("Invalid image type `%s'" xpm)
  image-type("" xpm nil)
  create-image("" xpm)
  eval((create-image "" (quote xpm)) nil)
  eval-expression((create-image "" (quote xpm)) nil)
  funcall-interactively(eval-expression (create-image "" (quote xpm)) nil)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)
Owner

Alexander-Miller commented Sep 27, 2017

Excellent. Shouldn't be long before, I'm done with this now.

Owner

Alexander-Miller commented Sep 27, 2017

Volunteers wanted!

I've pushed a possible fix to the no-images branch. Now I just need someone to install that version and confirm it works. All you need to do is clone the repo, check out the branch and include a :load-path property pointing to the local repo with the use-package declaration I assume you're using to install treemacs.

If it works, great! If it doesn't let me know the value of treemacs-no-images.

@Alexander-Miller It works! Looking forward to using this package. Thanks for the fix 😄

@Alexander-Miller I second the motion: it works!

Owner

Alexander-Miller commented Sep 27, 2017

All right, fix is on master.

Issue stays open for now, I need to change the readme, and will try to adapt the code so that you can force the no-image fallback by manually setting treemacs-no-images to t.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment