2

I have Magit installed and it used to work fine. However of late, I am running into the following error when I run magit-status.

Turning on magit-auto-revert-mode...done
run-hooks: Symbol’s function definition is void: closure

I have tried deleting elpa and reinstalling packages from scratch, new versions of Magit has also been released in the meantime, but none of those helped solve the problem. This is what I get with (setq debug-on-error t)

Debugger entered--Lisp error: (void-function closure)
  closure()
  run-hooks(magit-post-display-buffer-hook)
  magit-display-buffer(#<buffer magit: dotemacs>)
  magit-setup-buffer-internal(magit-status-mode nil ((magit-buffer-diff-args ("--no-ext-diff")) (magit-buffer-diff-files nil) (magit-buffer-log-args ("-n256" "--decorate")) (magit-buffer-log-files nil)))
  magit-status-setup-buffer("/home/swarnendu/github/dotemacs/")
  magit-status(nil ((7 . 4) (("/home/swarnendu/github/dotemacs/" . config) . #<hash-table equal 19/65 0x1558fd48cbb1>) (("/home/swarnendu/github/dotemacs/" . magit-toplevel) . "/home/swarnendu/github/dotemacs/") (("/home/swarnendu/github/dotemacs/" "rev-parse" "--show-cdup") . "") (("/home/swarnendu/github/dotemacs/" "rev-parse" "--show-toplevel") . "/home/swarnendu/github/dotemacs")))
  funcall-interactively(magit-status nil ((7 . 4) (("/home/swarnendu/github/dotemacs/" . config) . #<hash-table equal 19/65 0x1558fd48cbb1>) (("/home/swarnendu/github/dotemacs/" . magit-toplevel) . "/home/swarnendu/github/dotemacs/") (("/home/swarnendu/github/dotemacs/" "rev-parse" "--show-cdup") . "") (("/home/swarnendu/github/dotemacs/" "rev-parse" "--show-toplevel") . "/home/swarnendu/github/dotemacs")))
  call-interactively(magit-status nil nil)
  command-execute(magit-status)

I am using GNU Emacs 28.0.50 on Ubuntu 18.04. I get the same error with Emacs 26.3. Please let me know how can I resolve this problem, thanks.

5
Debugger entered--Lisp error: (void-function closure)
  closure()
  run-hooks(magit-post-display-buffer-hook)

You should see that as a hint as to what to do next:

  1. Inspect the value of magit-post-display-buffer-hook (using M-x describe-variable).
  2. Grep you ~/.emacs.d for magit-post-display-buffer-hook (using M-x rgrep).

Inspect the things that you find. Maybe comment some of them to narrow things down.

It's probably not an issue in Magit or we would have heard about it already. It could of course be a very recent regression but is more likely its an issue in some third-party package or even more likely your configuration.

Magit provides some tooling to help you figure out whether the issue is in Magit or your own configuration.

| improve this answer | |
  • Thanks for the tip. My configuration had the following to open Magit buffer in a full frame. ``` (magit-post-display-buffer-hook #'(lambda () (when (derived-mode-p 'magit-status-mode) (delete-other-windows)))) ``` Disabling it allows Magit to work. – Swarnendu Biswas Apr 2 at 10:11
  • You shouldn't #'quote lambda forms. Maybe that's all there is to it. – tarsius Apr 2 at 11:37
  • Well, you shouldn't use '(lambda...), but function-quoting with #'(lambda...) should (I believe) be entirely equivalent to unquoted (but self-quoting) (lambda...). – phils Apr 2 at 12:36
  • If the user is switching between (unstable) Emacs 28.0.50 and 26.3, I am curious as to whether the relevant files were byte-compiled by the same version in which they were loaded. – phils Apr 2 at 12:40
  • 1
    I would advise to never add lambda forms to hook variables at all, though. Always use named functions (i.e. symbols) in hooks -- it eliminates a number of problems and potential problems. – phils Apr 2 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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