Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error after updating to latest: "root-closed" icon is not loaded when using doom theme for treemacs #752

Closed
mcraveiro opened this issue Dec 30, 2020 · 11 comments

Comments

@mcraveiro
Copy link
Contributor

mcraveiro commented Dec 30, 2020

Hi treemacs developers,

thanks very much for a great package. This morning I updated my packages to latest, getting the following versions:

  • treemacs: 20201229.2326
  • treemacs-icons-dired: 20201005.1309
  • treemacs-magit: 20201025.957
  • treemacs-projectile: 20200530.2129

My emacs version is the standard one on Debian testing:

GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.16.0) of 2020-11-07, modified by Debian

After the update, when I try to start treemacs I get:

(wrong-type-argument char-or-string-p nil)

Turning on debug on errors, I see (with PATH_TO_PROJECTS replacing the actual paths for brevity):

Debugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
  treemacs--add-root-element(#s(treemacs-project :name "integration" :path "PATH_TO_PROJECTS/cpp_ref_impl/int..." :path-status local-readable :is-disabled? nil))
  treemacs--render-projects((#s(treemacs-project :name "integration" :path "PATH_TO_PROJECTS/cpp_ref_impl/int..." :path-status local-readable :is-disabled? nil) #s(treemacs-project :name "dogen_demo" :path "PATH_TO_PROJECTS/dogen_demo" :path-status local-readable :is-disabled? nil) #s(treemacs-project :name "dogen - integration" :path "PATH_TO_PROJECTS/dogen/integratio..." :path-status local-readable :is-disabled? nil) #s(treemacs-project :name "C# Ref Impl" :path "PATH_TO_PROJECTS/csharp_ref_impl/..." :path-status local-readable :is-disabled? nil) #s(treemacs-project :name "Finance" :path "PATH_TO_PROJECTS/Finance" :path-status local-readable :is-disabled? nil) #s(treemacs-project :name ".emacs.d" :path "/home/marco/.emacs.d" :path-status local-readable :is-disabled? nil)))
  treemacs--init()
  treemacs()
  funcall-interactively(treemacs)
<snip>

I tried debugging and the problem appears to be coming from this line:

(insert treemacs-icon-root-closed)

I will continue to investigate, but any ideas on what could be causing this are appreciated.

Many thanks for your time.

@Alexander-Miller
Copy link
Owner

treemacs-icon-root-closed

That's a new icon added recently. It's defined right here: https://github.com/Alexander-Miller/treemacs/blob/master/src/elisp/treemacs-icons.el#L261, so its value should be non-nil in treemacs buffers.

I cannot reproduce this locally so let's start with the basics: reinstall treemacs and restart Emacs. If that doesn't help check if evaluating these lines does:

    (treemacs-create-icon :file "vsc/root-closed.png"   :extensions (root-closed) :fallback "")
    (treemacs-create-icon :file "vsc/root-open.png"     :extensions (root-open)   :fallback "")

@mcraveiro
Copy link
Contributor Author

mcraveiro commented Dec 30, 2020

Thanks for the prompt response @Alexander-Miller. As you mention, the problem appears to be that the variable treemacs-icon-root-closed is nil. I checked my icons folder, and I can indeed see the PNG for it, located at icons/default/vsc/root-closed.png as expected. I will try uninstall and reinstall...

@mcraveiro
Copy link
Contributor Author

mcraveiro commented Dec 30, 2020

Uninstall and reinstall (with restarts) sadly did not help. I then ran the commands you supplied:

(treemacs-create-icon :file "vsc/root-closed.png"   :extensions (root-closed) :fallback "")

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  file-name-absolute-p(nil)
  f-absolute\?(nil)
  f-relative\?(nil)
  f-join(nil "vsc/root-closed.png")
  (let* ((icons-dir (progn (progn (aref treemacs--current-theme 2)))) (icon-path (f-join icons-dir "vsc/root-closed.png")) (icon-pair (let ((tui-icon "") (gui-icon (if (not ...) "" (let* ... ... ... ...)))) (cons gui-icon tui-icon))) (gui-icons (progn (progn (aref treemacs--current-theme 3)))) (tui-icons (progn (progn (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))) (progn (add-to-list 'treemacs--icon-symbols 'root-closed) (defvar treemacs-icon-root-closed nil)) (let ((list '(root-closed)) (it-index 0)) (while list (let ((it (car list))) (prog1 nil (puthash it gui-icon gui-icons)) (prog1 nil (puthash it tui-icon tui-icons))) (setq it-index (1+ it-index)) (setq list (cdr list)))))
  eval((let* ((icons-dir (progn (progn (aref treemacs--current-theme 2)))) (icon-path (f-join icons-dir "vsc/root-closed.png")) (icon-pair (let ((tui-icon "") (gui-icon (if ... "" ...))) (cons gui-icon tui-icon))) (gui-icons (progn (progn (aref treemacs--current-theme 3)))) (tui-icons (progn (progn (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))) (progn (add-to-list 'treemacs--icon-symbols 'root-closed) (defvar treemacs-icon-root-closed nil)) (let ((list '(root-closed)) (it-index 0)) (while list (let ((it (car list))) (prog1 nil (puthash it gui-icon gui-icons)) (prog1 nil (puthash it tui-icon tui-icons))) (setq it-index (1+ it-index)) (setq list (cdr list))))) nil)
  elisp--eval-last-sexp(nil)
<snip>

Seems like something is amiss in my machine with the creation of the default theme somehow...

@mcraveiro
Copy link
Contributor Author

And this does not look to healthy, right?

icons-dir is a variable without a source file.

Value
nil

@Alexander-Miller
Copy link
Owner

What's the value of treemacs--current-theme?

icons-dir is a variable without a source file.

icons-dir is a let-bound variable from the treemacs-create-icon, it should not be defined at all.

@mcraveiro
Copy link
Contributor Author

mcraveiro commented Dec 30, 2020

Yes, sorry, I'm very basic at elisp :-) but however, I now think I got edebug working and I am debugging through the function and checking the values of the variables. Bear with me and I'll give you some more details.

With regards to treemacs--current-theme, that looks healthier to the layperson, but mind you, I cannot see root-closed.

treemacs-current-theme.txt

@mcraveiro
Copy link
Contributor Author

Aha, could it be that the doom theme does not have this icon?

@mcraveiro
Copy link
Contributor Author

Bingo! removed doom themes and now all is good :-) But shouldn't there have been some kind of "fallback" mechanism kicking in?

Screenshot from 2020-12-30 12-15-59

@mcraveiro mcraveiro changed the title Error after updating to latest: (wrong-type-argument char-or-string-p nil) Error after updating to latest: root-closed icon is not loaded when using doom theme for treemacs Dec 30, 2020
@mcraveiro mcraveiro changed the title Error after updating to latest: root-closed icon is not loaded when using doom theme for treemacs Error after updating to latest: "root-closed" icon is not loaded when using doom theme for treemacs Dec 30, 2020
@mcraveiro
Copy link
Contributor Author

On the plus side, may I just say, these new icons look very swanky :-) great job, it looks very nice! I think I'll remove the doom theme altogether in favour of the default! :-)

@Alexander-Miller
Copy link
Owner

Yes, that's the problem. The change needs to be reported upstream. I hadn't considered that other themes would need to know about the icon, so there's no fallback. But even if there was, the basic "root" icon is now obsolete, so I would want to remove the fallback eventually. So this update inconvenience would only be postponed not solved. Might as well get if over with sooner instead of later.

I'll go report this upstream with doom. If you do decide to keep using doom in the meatime here's a workaround:

(-let [root (ht-get (treemacs-theme->gui-icons treemacs--current-theme) 'root)]
  (treemacs-modify-theme "doom-atom"
    :config
    (progn
      (treemacs-create-icon :icon root :extensions (root-closed) :fallback "")
      (treemacs-create-icon :icon root :extensions (root-open)   :fallback ""))))

@mcraveiro
Copy link
Contributor Author

mcraveiro commented Dec 30, 2020

Actually, your default theme looks far cooler so I'm now sticking to that :-D Thanks very much for all your help and for the very quick turnaround. I'll close the ticket as I am now a happy customer, but feel free to reopen if as required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants