dimitri/el-get

sly: Symbol's value as a variable is void

Closed this issue · 8 comments

mnewt commented

Can someone help me understand why, in some cases, el-get runs :after procedures before fully loading the package? Here is a recipe snippet that exhibits the behavior.

(setq
 el-get-sources
 '((:name sly
           :after (define-key sly-prefix-map (kbd "M-h") 'sly-documentation-lookup)))

This is loaded in the normal way:

(setq my:el-get-packages
      (loop for src in el-get-sources collect (el-get-source-name src)))
(el-get 'sync my:el-get-packages)

When emacs starts, I get this error:
Error (el-get): while initializing sly: Symbol’s value as variable is void: sly-prefix-map

Many thanks

Do you have another sly.el somewhere in your load path (eg a file with settings for sly)?

Try M-x list-load-path-shadows

mnewt commented

No, there is nothing for sly listed there

Hmm, did you set el-get-is-lazy?

Here is a recipe snippet that exhibits the behavior.

(setq
 el-get-sources
 '((:name sly
           :after (define-key sly-prefix-map (kbd "M-h") 'sly-documentation-lookup)))

That can't be the whole snippet, can it? You haven't defined where to install sly from.

mnewt commented

Right you are. Here is a complete init.el which reproduces the problem for me with Emacs 25.3.1 on macOS:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Package.el
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "https://melpa.org/packages/")))

;; Added by Package.el.  This must come before configurations of
;; installed packages.  Don't delete this line.  If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; El-Get
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(add-to-list 'load-path "~/.emacs.d/el-get/el-get")

(unless (require 'el-get nil 'noerror)
  (with-current-buffer
      (url-retrieve-synchronously
       "https://github.com/dimitri/el-get/raw/master/el-get-install.el")
    (goto-char (point-max))
    (eval-print-last-sexp)))

;; Use MELPA
(require 'el-get-elpa)
;; Build the El-Get copy of the package.el packages if we have not
;; built it before.  Be sure to run this before installing new packages
(unless (file-directory-p el-get-recipe-path-elpa)
  (el-get-elpa-build-local-recipes))

;; set local recipes
(setq
 el-get-sources
 '((:name el-get)
   (:name sly
          :type github
          :pkgname "joaotavora/sly"
          :after (define-key sly-prefix-map (kbd "M-h") 'sly-documentation-lookup))))

(setq my:el-get-packages
      (loop for src in el-get-sources collect (el-get-source-name src)))

;; install new packages and init already installed packages
(el-get 'sync my:el-get-packages)

And here is the error upon launching emacs:

Debugger entered--Lisp error: (void-variable sly-prefix-map)
  (define-key sly-prefix-map (kbd "M-h") (quote sly-documentation-lookup))

Oh, I remember how it works now. The normal case is that :after always runs eagerly. You have to set el-get-is-lazy, or put :lazy t in the recipe in order to delay the evaluation.

mnewt commented

That's great, it works!

I didn't get that at all from the docs. Are you interested in a small pull request to expand the explanation of those two lazy settings?

Thanks again

I didn't get that at all from the docs. Are you interested in a small pull request to expand the explanation of those two lazy settings?

Sure!