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

Can't install using Straight.el: Wrong type argument: listp, 1 #314

Open
tjtrabue opened this issue Mar 1, 2023 · 2 comments
Open

Can't install using Straight.el: Wrong type argument: listp, 1 #314

tjtrabue opened this issue Mar 1, 2023 · 2 comments

Comments

@tjtrabue
Copy link

tjtrabue commented Mar 1, 2023

Greetings everyone,

First of all, just let me say thank you for this amazing plugin. I've used helpful for years, and I absolutely love it! In fact, I find it hard to get around Emacs' help system without it now that I'm used to helpful's amazing output.

Recently, I upgraded to Emacs version 30.0.50, the latest master branch commit (specifically 42f46913884c5e431a0e6cc80b1808fc0ca636cf), and ever since then when I try to install helpful using the straight.el package manager I am met with the following error:

Wrong type argument: listp, 1

I would love to provide you with a full stack-trace of the error in question, but even when I run (setq debug-on-error t) in my ~/.emacs file I never get presented with the full trace. I don't know why since that usually works. Instead of popping open a debug buffer, I see only that short error message about the wrong type argument presented in another window, as well as the usual Emacs advice telling me to re-run emacs from the command line with the --debug-init option, although even after running emacs with that option I get the same result.

I should note that, before this event, I have never had a problem installing helpful using straight.el, so I don't think it's a problem with straight.el. Here's my use-package directive I use to install helpful (and note that I have configured use-package to always install packages using straight.el):

  (use-package helpful
    :ensure t
    :defer t
    :general
    (general-def
      ;; Replace standard help functions with helpful functions.
      "C-h f" 'helpful-callable
      "C-h v" 'helpful-variable
      "C-h k" 'helpful-key
      ;; Other useful keybindings.
      "C-h C" 'helpful-command
      "C-h F" 'helpful-function)
    (my/user-leader-def
      "C-d" 'helpful-at-point)
    (general-def 'normal emacs-lisp-mode-map
      "K" 'helpful-at-point))

This has been my configuration for years, too, so I don't think it's a configuration problem. Has anyone else had this problem installing helpful?

Thank you all so much,

-Tom Trabue

@tjtrabue
Copy link
Author

tjtrabue commented Mar 1, 2023

So, I'm afraid I must tuck my tail. I discovered that the problem was indeed with straight.el, after all, and I apologize for not digging into their documentation before I opened this issue. Apparently in the last 6 months or so, straight.el enabled an experimental native-compilation feature if one is using Emacs built with native-compilation support, which I am. Thus, straight.el will automatically attempt to compile all packages it installs by default, and for some reason helpful.el throws that wrong type argument error when compiled. Anyways, the fix was to add the following configuration to my use-package directive:

  (use-package helpful
    :ensure t
    :defer t
    ;; THIS IS THE NEW PART
    :straight
    (helpful :type git :host github :repo "Wilfred/helpful"
             ;; Disable native-compilation when installing helpful to avoid compile-time error.
             :build (:not native-compile))
    :general
    (general-def
      ;; Replace standard help functions with helpful functions.
      "C-h f" 'helpful-callable
      "C-h v" 'helpful-variable
      "C-h k" 'helpful-key
      ;; Other useful keybindings.
      "C-h C" 'helpful-command
      "C-h F" 'helpful-function)
    (my/user-leader-def
      "C-d" 'helpful-at-point)
    (general-def 'normal emacs-lisp-mode-map
      "K" 'helpful-at-point))

EDIT: This did not solve my problem. Please see the next comment for a true fix.

@tjtrabue
Copy link
Author

tjtrabue commented Mar 2, 2023

Ok, this really baked my noodle, but I finally figured out what the real problem was. My second comment was incorrect. The problem has nothing to do with straight.el's native-compilation feature. In fact, the issue has nothing to do with helpful at all! It was one of helpful's dependencies: elisp-refs. For some reason, straight.el cannot generate the autoloads file for elisp-refs. I'm not sure why, but it's definitely the autoloads step of straight's build process that fails with the Wrong type error: listp, 1 exception.

The solution was to add a specific build recipe for elisp-refs to my ~/.emacs file that skips the autoloads phase:

;; We have to specify how to install and load elisp-refs.el
(use-package elisp-refs
  :demand t
  :straight
  (elisp-refs :type git :host github :repo "Wilfred/elisp-refs"
                   ;; Skip the autoloads phase because straight.el can't seem to get it right.
                   :build (:not autoloads)))

(use-package helpful
    ;; THIS IS NEW: We must wait until elisp-refs has loaded, otherwise helpful will try its own
    ;; recipe for installing elisp-refs, which will break.
    :after elisp-refs
    :ensure t
    :defer t
    ;; No need for a :straight directive at all anymore.
    :general
    (general-def
      ;; Replace standard help functions with helpful functions.
      "C-h f" 'helpful-callable
      "C-h v" 'helpful-variable
      "C-h k" 'helpful-key
      ;; Other useful keybindings.
      "C-h C" 'helpful-command
      "C-h F" 'helpful-function)
    (my/user-leader-def
      "C-d" 'helpful-at-point)
    (general-def 'normal emacs-lisp-mode-map
      "K" 'helpful-at-point))

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

1 participant