Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Issue with using the `use-package-always-ensure` option #190
Comments
|
Can you run (pp-to-string (macroexpand '(use-package defuns))) |
kaushalmodi
commented
Mar 23, 2015
|
Sure. Here is the output of Debugger entered--Lisp error: (error "Package `defuns-' is unavailable")
signal(error ("Package `defuns-' is unavailable"))
error("Package `%s-%s' is unavailable" defuns "")
package-compute-transaction(nil ((defuns)))
package-install(defuns)
(progn (package-install package))
(if (not (package-installed-p package)) (progn (package-install package)))
use-package-ensure-elpa(defuns)
(progn (require (quote package)) (use-package-ensure-elpa package-name))
(if package-name (progn (require (quote package)) (use-package-ensure-elpa package-name)))
(let ((package-name (or (and (eq ensure t) name-symbol) ensure))) (if package-name (progn (require (quote package)) (use-package-ensure-elpa package-name))))
(let ((body (use-package-process-keywords name-symbol rest state))) (let ((package-name (or (and (eq ensure t) name-symbol) ensure))) (if package-name (progn (require (quote package)) (use-package-ensure-elpa package-name)))) body)
use-package-handler/:ensure(defuns :ensure t (:config (t)) nil)
funcall(use-package-handler/:ensure defuns :ensure t (:config (t)) nil)
(if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler)))
(let* ((handler (concat "use-package-handler/" (symbol-name keyword))) (handler-sym (intern handler))) (if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler))))
(let* ((keyword (car plist)) (arg (cadr plist)) (rest (cddr plist))) (if (keywordp keyword) nil (use-package-error (format "%s is not a keyword" keyword))) (let* ((handler (concat "use-package-handler/" (symbol-name keyword))) (handler-sym (intern handler))) (if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler)))))
(if (null plist) nil (let* ((keyword (car plist)) (arg (cadr plist)) (rest (cddr plist))) (if (keywordp keyword) nil (use-package-error (format "%s is not a keyword" keyword))) (let* ((handler (concat "use-package-handler/" (symbol-name keyword))) (handler-sym (intern handler))) (if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler))))))
use-package-process-keywords(defuns (:ensure t :config (t)))
(macroexp-progn (use-package-process-keywords name-symbol args*))
(let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let ((buf (get-buffer-create "*use-package*"))) (save-current-buffer (set-buffer buf) (delete-region (point-min) (point-max)) (emacs-lisp-mode) (insert (pp-to-string body))) buf)))) body)
(let* ((name-symbol (if (stringp name) (intern name) name)) (args0 (use-package-plist-maybe-put (use-package-normalize-plist name-symbol args) :config (quote (t)))) (args* (use-package-sort-keywords (if use-package-always-ensure (use-package-plist-maybe-put args0 :ensure use-package-always-ensure) args0)))) (if (and (boundp (quote byte-compile-current-file)) byte-compile-current-file) (setq args* (use-package-plist-cons args* :preface (cons (quote eval-when-compile) (append (mapcar (function ...) (plist-get args* :defines)) (list (list ... ... ... ...))))))) (let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let ((buf ...)) (save-current-buffer (set-buffer buf) (delete-region ... ...) (emacs-lisp-mode) (insert ...)) buf)))) body))
(if (member :disabled args) nil (let* ((name-symbol (if (stringp name) (intern name) name)) (args0 (use-package-plist-maybe-put (use-package-normalize-plist name-symbol args) :config (quote (t)))) (args* (use-package-sort-keywords (if use-package-always-ensure (use-package-plist-maybe-put args0 :ensure use-package-always-ensure) args0)))) (if (and (boundp (quote byte-compile-current-file)) byte-compile-current-file) (setq args* (use-package-plist-cons args* :preface (cons (quote eval-when-compile) (append (mapcar ... ...) (list ...)))))) (let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let (...) (save-current-buffer ... ... ... ...) buf)))) body)))
(lambda (name &rest args) "Declare an Emacs package by specifying a group of configuration options.\n\nFor full documentation, please see the README file that came with\nthis file. Usage:\n\n (use-package package-name\n [:keyword [option]]...)\n\n:init Code to run before PACKAGE-NAME has been loaded.\n:config Code to run after PACKAGE-NAME has been loaded. Note that if\n loading is deferred for any reason, this code does not execute\n until the lazy load has occurred.\n:preface Code to be run before everything except `:disabled'; this can\n be used to define functions for use in `:if', or that should be\n seen by the byte-compiler.\n\n:mode Form to be added to `auto-mode-alist'.\n:interpreter Form to be added to `interpreter-mode-alist'.\n\n:commands Define autoloads for commands that will be defined by the\n package. This is useful if the package is being lazily loaded,\n and you wish to conditionally call functions in your `:init'\n block that are defined in the package.\n\n:bind Bind keys, and define autoloads for the bound commands.\n:bind* Bind keys, and define autoloads for the bound commands,\n *overriding all minor mode bindings*.\n:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the\n package. This is like `:bind', but for keymaps.\n:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings\n\n:defer Defer loading of a package -- this is implied when using\n `:commands', `:bind', `:bind*', `:mode' or `:interpreter'.\n This can be an integer, to force loading after N seconds of\n idle time, if the package has not already been loaded.\n:demand Prevent deferred loading in all cases.\n\n:if EXPR Initialize and load only if EXPR evaluates to a non-nil value.\n:disabled The package is ignored completely if this keyword is present.\n:defines Declare certain variables to silence the byte-compiler.\n:functions Declare certain functions to silence the byte-compiler.\n:load-path Add to the `load-path' before attempting to load the package.\n:diminish Support for diminish.el (if installed).\n:ensure Loads the package using package.el if necessary.\n:pin Pin the package to an archive." (if (member :disabled args) nil (let* ((name-symbol (if (stringp name) (intern name) name)) (args0 (use-package-plist-maybe-put (use-package-normalize-plist name-symbol args) :config (quote (t)))) (args* (use-package-sort-keywords (if use-package-always-ensure (use-package-plist-maybe-put args0 :ensure use-package-always-ensure) args0)))) (if (and (boundp (quote byte-compile-current-file)) byte-compile-current-file) (setq args* (use-package-plist-cons args* :preface (cons (quote eval-when-compile) (append ... ...))))) (let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let ... ... buf)))) body))))(defuns)
(use-package defuns)
eval-buffer(#<buffer *load*> nil "/home/kmodi/.emacs.d/init.el" nil t) ; Reading at buffer position 4835
load-with-code-conversion("/home/kmodi/.emacs.d/init.el" "/home/kmodi/.emacs.d/init.el" t t)
load("/home/kmodi/.emacs.d/init" t t)
#[0 "�\205\262If I try to eval Eager macro-expansion failure: (error "Package `defuns-' is unavailable") [2 times]
package-compute-transaction: Package `defuns-' is unavailableAll of this was while But in the same session, after I eval "(if
(not
(require 'defuns nil t))
(ignore
(display-warning 'use-package
(format \"Could not load %s\" 'defuns)
:error)))
" |
|
Setting |
It's attempting to install a non-existent package I think what @kaushalmodi meant in 0e87ada#commitcomment-10344705 is that |
kaushalmodi
commented
Mar 23, 2015
|
@npostavs Right on!
In the example of this (defun prepend-path ( my-path )
(setq load-path (cons (expand-file-name my-path) load-path)))
(prepend-path (concat user-emacs-directory "/elisp"))(My |
That could be problematic since the check happens at macroexpand time, while (add-to-list 'load-path "~/src/my-elisp/") ; assume "my-functions.el" is in "~/src/my-elisp"
(use-package my-functions
:ensure t)At macroexpand time, |
|
Could someone who relies on |
kaushalmodi
commented
Mar 23, 2015
|
Also it looks like I have a package Here is how I load it: (use-package de-ansi
:load-path "elisp/de-ansi"
:commands (de-ansify)
:init
(progn
;; ...
))But Debugger entered--Lisp error: (error "Package `de-ansi-' is unavailable")
signal(error ("Package `de-ansi-' is unavailable"))
error("Package `%s-%s' is unavailable" de-ansi "")
package-compute-transaction(nil ((de-ansi)))
package-install(de-ansi)
(progn (package-install package))
(if (not (package-installed-p package)) (progn (package-install package)))
use-package-ensure-elpa(de-ansi)
(progn (require (quote package)) (use-package-ensure-elpa package-name))
(if package-name (progn (require (quote package)) (use-package-ensure-elpa package-name)))
(let ((package-name (or (and (eq ensure t) name-symbol) ensure))) (if package-name (progn (require (quote package)) (use-package-ensure-elpa package-name))))
(let ((body (use-package-process-keywords name-symbol rest state))) (let ((package-name (or (and (eq ensure t) name-symbol) ensure))) (if package-name (progn (require (quote package)) (use-package-ensure-elpa package-name)))) body)
use-package-handler/:ensure(de-ansi :ensure t (:load-path ("/home/kmodi/.emacs.d/elisp/de-ansi") :commands (de-ansify) :init ((progn (bind-to-modi-map "d" de-ansify))) :config (t) :defer t) nil)
funcall(use-package-handler/:ensure de-ansi :ensure t (:load-path ("/home/kmodi/.emacs.d/elisp/de-ansi") :commands (de-ansify) :init ((progn (bind-to-modi-map "d" de-ansify))) :config (t) :defer t) nil)
(if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler)))
(let* ((handler (concat "use-package-handler/" (symbol-name keyword))) (handler-sym (intern handler))) (if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler))))
(let* ((keyword (car plist)) (arg (cadr plist)) (rest (cddr plist))) (if (keywordp keyword) nil (use-package-error (format "%s is not a keyword" keyword))) (let* ((handler (concat "use-package-handler/" (symbol-name keyword))) (handler-sym (intern handler))) (if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler)))))
(if (null plist) nil (let* ((keyword (car plist)) (arg (cadr plist)) (rest (cddr plist))) (if (keywordp keyword) nil (use-package-error (format "%s is not a keyword" keyword))) (let* ((handler (concat "use-package-handler/" (symbol-name keyword))) (handler-sym (intern handler))) (if (functionp handler-sym) (funcall handler-sym name-symbol keyword arg rest state) (use-package-error (format "Keyword handler not defined: %s" handler))))))
use-package-process-keywords(de-ansi (:ensure t :load-path ("/home/kmodi/.emacs.d/elisp/de-ansi") :commands (de-ansify) :init ((progn (bind-to-modi-map "d" de-ansify))) :config (t) :defer t))
(macroexp-progn (use-package-process-keywords name-symbol args*))
(let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let ((buf (get-buffer-create "*use-package*"))) (save-current-buffer (set-buffer buf) (delete-region (point-min) (point-max)) (emacs-lisp-mode) (insert (pp-to-string body))) buf)))) body)
(let* ((name-symbol (if (stringp name) (intern name) name)) (args0 (use-package-plist-maybe-put (use-package-normalize-plist name-symbol args) :config (quote (t)))) (args* (use-package-sort-keywords (if use-package-always-ensure (use-package-plist-maybe-put args0 :ensure use-package-always-ensure) args0)))) (if (and (boundp (quote byte-compile-current-file)) byte-compile-current-file) (setq args* (use-package-plist-cons args* :preface (cons (quote eval-when-compile) (append (mapcar (function ...) (plist-get args* :defines)) (list (list ... ... ... ...))))))) (let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let ((buf ...)) (save-current-buffer (set-buffer buf) (delete-region ... ...) (emacs-lisp-mode) (insert ...)) buf)))) body))
(if (member :disabled args) nil (let* ((name-symbol (if (stringp name) (intern name) name)) (args0 (use-package-plist-maybe-put (use-package-normalize-plist name-symbol args) :config (quote (t)))) (args* (use-package-sort-keywords (if use-package-always-ensure (use-package-plist-maybe-put args0 :ensure use-package-always-ensure) args0)))) (if (and (boundp (quote byte-compile-current-file)) byte-compile-current-file) (setq args* (use-package-plist-cons args* :preface (cons (quote eval-when-compile) (append (mapcar ... ...) (list ...)))))) (let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let (...) (save-current-buffer ... ... ... ...) buf)))) body)))
(lambda (name &rest args) "Declare an Emacs package by specifying a group of configuration options.\n\nFor full documentation, please see the README file that came with\nthis file. Usage:\n\n (use-package package-name\n [:keyword [option]]...)\n\n:init Code to run before PACKAGE-NAME has been loaded.\n:config Code to run after PACKAGE-NAME has been loaded. Note that if\n loading is deferred for any reason, this code does not execute\n until the lazy load has occurred.\n:preface Code to be run before everything except `:disabled'; this can\n be used to define functions for use in `:if', or that should be\n seen by the byte-compiler.\n\n:mode Form to be added to `auto-mode-alist'.\n:interpreter Form to be added to `interpreter-mode-alist'.\n\n:commands Define autoloads for commands that will be defined by the\n package. This is useful if the package is being lazily loaded,\n and you wish to conditionally call functions in your `:init'\n block that are defined in the package.\n\n:bind Bind keys, and define autoloads for the bound commands.\n:bind* Bind keys, and define autoloads for the bound commands,\n *overriding all minor mode bindings*.\n:bind-keymap Bind a key prefix to an auto-loaded keymap defined in the\n package. This is like `:bind', but for keymaps.\n:bind-keymap* Like `:bind-keymap', but overrides all minor mode bindings\n\n:defer Defer loading of a package -- this is implied when using\n `:commands', `:bind', `:bind*', `:mode' or `:interpreter'.\n This can be an integer, to force loading after N seconds of\n idle time, if the package has not already been loaded.\n:demand Prevent deferred loading in all cases.\n\n:if EXPR Initialize and load only if EXPR evaluates to a non-nil value.\n:disabled The package is ignored completely if this keyword is present.\n:defines Declare certain variables to silence the byte-compiler.\n:functions Declare certain functions to silence the byte-compiler.\n:load-path Add to the `load-path' before attempting to load the package.\n:diminish Support for diminish.el (if installed).\n:ensure Loads the package using package.el if necessary.\n:pin Pin the package to an archive." (if (member :disabled args) nil (let* ((name-symbol (if (stringp name) (intern name) name)) (args0 (use-package-plist-maybe-put (use-package-normalize-plist name-symbol args) :config (quote (t)))) (args* (use-package-sort-keywords (if use-package-always-ensure (use-package-plist-maybe-put args0 :ensure use-package-always-ensure) args0)))) (if (and (boundp (quote byte-compile-current-file)) byte-compile-current-file) (setq args* (use-package-plist-cons args* :preface (cons (quote eval-when-compile) (append ... ...))))) (let ((body (macroexp-progn (use-package-process-keywords name-symbol args*)))) (if use-package-debug (display-buffer (save-current-buffer (let ... ... buf)))) body))))(de-ansi :load-path "elisp/de-ansi" :commands (de-ansify) :init (progn (bind-to-modi-map "d" de-ansify)))
(use-package de-ansi :load-path "elisp/de-ansi" :commands (de-ansify) :init (progn (bind-to-modi-map "d" de-ansify)))
eval-buffer(#<buffer *load*-146766> nil "/home/kmodi/.emacs.d/setup-files/setup-de-ansi.el" nil t) ; Reading at buffer position 174
load-with-code-conversion("/home/kmodi/.emacs.d/setup-files/setup-de-ansi.el" "/home/kmodi/.emacs.d/setup-files/setup-de-ansi.el" nil t)
#<subr require>(setup-de-ansi nil nil)
ad-Advice-require(#<subr require> setup-de-ansi)
apply(ad-Advice-require #<subr require> setup-de-ansi)
require(setup-de-ansi)
eval-buffer(#<buffer *load*> nil "/home/kmodi/.emacs.d/init.el" nil t) ; Reading at buffer position 5489
load-with-code-conversion("/home/kmodi/.emacs.d/init.el" "/home/kmodi/.emacs.d/init.el" t t)
load("/home/kmodi/.emacs.d/init" t t)
#[0 "�\205\262 |
brontitall
commented
Mar 23, 2015
I don't have enough experience to be sure, but personally I think I'd like to see it at evaluation time. This might solve my issue of |
|
|
brontitall
commented
Mar 23, 2015
I don't want to sound like a broken record on this, but this is not the case, since Perhaps if |
brontitall
commented
Mar 24, 2015
|
Just an example to show what I mean:
|
brontitall
commented
Mar 24, 2015
|
Actually, now that I've updated my Better example:
|
|
Right, I should have clarified: If you need a conditional, you must use
I think the ultimate answer may be to move |
|
It need to be at compile time for performance.. I have probably successfully stopped requiring 'package at load time as well which saved me just about 150ms startup time. I stopped using 'package for setting up my load path along time ago since package-initialize does too much stuff. What I have now is based on @jwiegley's load-path.el from some years ago: It's quite messy right now but it get's the job done. I just recently added the byte compilation of load-path.el/the load-path variable and not requiring 'package at load time, If this works well I will also look into letting 'package initialize the load-path variable at byte compilation time since It won't matter as much If I include the result in the resulting .elc. I'm down to about 1s emacs start time now, |
|
I vote to remove use-package-always-ensure instead of again heading towards a needlessly complicated use-package. I'm totally fine with specifying my :ensure's manually. |
|
Anyone else? I'm all for removing features. I would even like to move |
kaushalmodi
commented
Mar 24, 2015
|
I am fine with that. But still would you consider #190 (comment) to be a bug? Should |
@kaushalmodi's situation can be solved with |
kaushalmodi
commented
Mar 24, 2015
|
@npostavs Yes, but I am thinking of using this solution I found on github to emulate the Here is the reasoning:
Example: (use-package de-ansi
:load-path "elisp/de-ansi" |
|
@kaushalmodi I think the problem is that we don't want to move |
kaushalmodi
commented
Mar 24, 2015
|
@thomasf The actual load path entered by the user doesn't need to be checked for validity. If the user used That should be possible at compile time, correct? |
|
@kaushalmodi Yeah, that should work. It it's still slightly more complicated than I would like when keywords starts affecting each other in non obvious ways,. |
|
|
kaushalmodi
commented
Mar 24, 2015
|
@jwiegley Do you think it will be a fair modification to process |
|
In the new architecture, it's as easy as moving symbols in a list, and verifying that correct semantics are preserved by way of manual testing. |
|
But we still have the question of exactly what |
|
arg |
|
And |
kaushalmodi
commented
Mar 24, 2015
|
|
|
Ah, so |
jwiegley
added
ensure
bug
labels
Apr 6, 2015
npostavs
referenced this issue
in dimitri/el-get
Apr 14, 2015
Closed
Extend use-package to :ensure packages are installed via el-get #2156
xakz
commented
Sep 23, 2015
|
Same problem for me, I'm not a lisp expert but it looks like the use-package macro add a `-' at the end of the package name. That said, I think the :ensure and :pin should be in another package. maybe a package+.el ;) |
This was referenced Oct 28, 2015
kaushalmodi
referenced
this issue
in Silex/emacs-config
Oct 27, 2016
|
Is this solved now? |
kaushalmodi
commented
Feb 18, 2017
•
To summarizeThis works (setq use-package-always-ensure t)
(use-package my-local-pkg
:ensure nil
:load-path "my-local-pkg")But this does not: (setq use-package-always-ensure t)
(use-package my-local-pkg
:load-path "my-local-pkg")The second snippet above still tries to install Would it be possible to effectively do ":ensure nil" if user has provided the ":load-path"? |
|
@kaushalmodi you could accomplish what you are seeking by customizing the new
This assumes any local package that exists in a folder of the same name at the root level of your emacs is added to your load-path and used, otherwise it will fall back to |
|
What do you all think should be the default behavior? |
kaushalmodi
commented
Feb 20, 2017
|
@waymondo Thanks for the code snippet, I will understand and try it out when I get to a computer. @jwiegley I would of course want the default behavior to not auto-install package if load-path is explicitly mentioned. :) My reasoning is that the user would specify the load-path only if they don't want to use the GNU Elpa/Melpa/etc package versions, or if the package doesn't exist on external repositories. That indirectly means that an attempt to fetch the package from outside should not be made. To pose this scenario from a different angle, when would one want to specify |
ivan-m
referenced this issue
in edvorg/req-package
Mar 15, 2017
Closed
`:loader :path` packages keep trying to get installed #40
jacksgt
commented
May 3, 2017
|
I spent a week trying to figure out why use-package wanted to download my local packages from the archives, even though I had explicitly set the Please make the behavior suggested above (no auto-installation of packages with explicit load-path) the default. |
Alexander-Shukaev
commented
Jul 10, 2017
|
Please, fix it as has already been suggested by multiple users. It's simply odd to attempt to install (the most-likely non-existent) packages from online archives when |
kaushalmodi commentedMar 23, 2015
Hi ,
I tried out the new option and set it to
t.But it gives me this error:
I have the below in my emacs init:
The
defuns.elis present in thatelisp/path.But is looks like
defunsis being tried to be installed by the package manager (even though it is available in theload-path) when this new option ist(or probably because:ensureist).