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

Emacs dashboard breaks daemon with latest emacs pgtk native comp build #373

Open
drishal opened this issue Apr 24, 2022 · 17 comments
Open

Comments

@drishal
Copy link

drishal commented Apr 24, 2022

Hello, for some reason if I use emacs --daemon it fails to detach, does not return the prompt and does not properly start the client on using the latest git on emacs dashboard
tried a minimal config as here
dashboard-test .el.txt

(github for some reason does not like .el so uploading as .txt)

EDIT
the command just hangs here
image

Notes:
emacsPgtkNativeComp Built on nixos unstable with home-manager at this commit nix-community/emacs-overlay@3244c10

@drishal
Copy link
Author

drishal commented Apr 26, 2022

seems like M-x dashboard-refresh-buffer does reload dashboard but for some reason (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*"))) prevents emacs --daemon from detaching, and in the actual emacs it loads the scratch buffer

Anyone having any ideas why its suddenly happening? this used to work perfectly fine a week back

on further inspection with emacs -Q I get this

command-line-1: Value returned by ‘initial-buffer-choice’ is not a live buffer: nil

@drishal
Copy link
Author

drishal commented Apr 26, 2022

UPDATE: Solved issue by adding

(dashboard-refresh-buffer)

LMFAO

idk why (dashboard-setup-startup-hook) was not starting up the dashboard buffer..hmm

Maybe please add (dashboard-refresh-buffer) in the readme

@jcs090218
Copy link
Member

jcs090218 commented Apr 26, 2022

Sorry for ignoring this issue. I think this is an existing issue for a long while.

Function (dashboard-refresh-buffer) has the flag dashboard-force-refresh to t. These are my guesses:

I think the first point would be my best guess since isn't daemon has to be called from the command line? 😕

@drishal
Copy link
Author

drishal commented Apr 26, 2022

Hmm according to someone on doom-emacs discord (on help-nondoom-users channel) this hook seems to reproduce the bug

(add-hook 'after-init-hook (lambda ()

@jcs090218
Copy link
Member

You mean the after-init-hook does not get called?

@drishal
Copy link
Author

drishal commented Apr 26, 2022

Hmm seems like it
tbh I am not really good with actually going through the package source so not that sure 😅

@jcs090218
Copy link
Member

Maybe try overriding the function dashboard-setup-startup-hook

(with-eval-after-load 'dashboard
  (defun dashboard-setup-startup-hook ()
    ;;(when (< (length command-line-args) 2)
    (add-hook 'after-init-hook (lambda ()
                                 ;; Display useful lists of items
                                 (dashboard-insert-startupify-lists)))
    (add-hook 'emacs-startup-hook (lambda ()
                                    (switch-to-buffer dashboard-buffer-name)
                                    (goto-char (point-min))
                                    (redisplay)
                                    (run-hooks 'dashboard-after-initialize-hook)))
    ;;)
    ))

place it in your init.el and see if that works?

@drishal
Copy link
Author

drishal commented Apr 26, 2022

this way?

(with-eval-after-load 'dashboard
  (defun dashboard-setup-startup-hook ()
    ;;(when (< (length command-line-args) 2)
    (add-hook 'after-init-hook (lambda ()
                                 ;; Display useful lists of items
                                 (dashboard-insert-startupify-lists)))
    (add-hook 'emacs-startup-hook (lambda ()
                                    (switch-to-buffer dashboard-buffer-name)
                                    (goto-char (point-min))
                                    (redisplay)
                                    (run-hooks 'dashboard-after-initialize-hook)))
    ;;)
    ))
(use-package dashboard
  :straight t
  :config
  (dashboard-setup-startup-hook)
)
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))

(the daemon still does not detach in this case)

@zadca123
Copy link

same problem here

@archer-65
Copy link

Same problem, on both Arch and NixOS

@alxleroux
Copy link

same

@ananthakumaran
Copy link

ananthakumaran commented Jun 5, 2022

NixOS user here, sharing a bit more context that might be useful in debugging the issue.

;; command-line-args
("/nix/store/qr4p11zqxppr4r8jz0ypvra3jbsil07k-emacs-pgtk-native-comp-20220528.0/bin/emacs" "-l" "cl-loaddefs" "-l" "nix-generated-autoload")
# ❯ tail $(which emacs)
    newNativeLoadPath+=("")
fi

export EMACSLOADPATH="${newLoadPath[*]}"
export emacsWithPackages_siteLisp=/nix/store/z9ara8c5g37k7dj936418l0kkb50ajis-emacs-packages-deps/share/emacs/site-lisp

export EMACSNATIVELOADPATH="${newNativeLoadPath[*]}"
export emacsWithPackages_siteLispNative=/nix/store/z9ara8c5g37k7dj936418l0kkb50ajis-emacs-packages-deps/share/emacs/native-lisp:

exec /nix/store/qr4p11zqxppr4r8jz0ypvra3jbsil07k-emacs-pgtk-native-comp-20220528.0/bin/emacs -l cl-loaddefs -l nix-generated-autoload "$@"

I think the assumption that user don't want to see dashboard when command line arguments are passed doesn't seem to play well with the newer changes at nix (or other) package level #23

@ricardoricho
Copy link
Contributor

Hi, I think there are two issues, need to change get-buffer to get-buffer-create as @willbush suggested here #334 (comment) and there is a "bug" in

(when (< (length command-line-args) 2)
there should be if instead of whenso the "proper" hook get added (I don't know why they are different hooks)

Try this config:

(use-package dashboard
  :ensure t
  :init
  (add-hook 'after-init-hook #'dashboard-insert-sartupify-lists)
  :config
  (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))))

Hope this helps.

@drishal
Copy link
Author

drishal commented Jun 6, 2022

Hmm either using (dashboard-refresh-buffer) or get-buffer-create works for now

@jcs090218
Copy link
Member

I think the issue is

(let ((buffer-exists (buffer-live-p (get-buffer dashboard-buffer-name)))

and

(not buffer-exists))

These lines was added 6 years ago. I assumed we no longer need these lines since get-buffer-create should be pretty safe? 😕

@jcs090218
Copy link
Member

Okay, I encountered this in the normal client (no daemon) as well. I think the issue is emacs trying to pick up the *dashboard* buffer but it hasn't been created. But since dashboard is the last thing to load, we should just use get-buffer-create function instead.

Updated the documentation, in #382.

@port19x
Copy link

port19x commented Jun 7, 2023

What worked for me was replacing
:hook (after-init . dashboard-refresh-buffer)
with :hook (server-after-make-frame . dashboard-refresh-buffer)

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

8 participants