Hi!
I'm trying to use the :pin feature and just can't get it working. I'm not sure if it's a bug or it's just me not understanding how to do this right.
Minimal init.el to reproduce the issue (checked on OSX and Emacs 24.5.1):
;; ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/") t)
(setq package-pinned-packages '((use-package . "melpa")))
;; note, that I'm initializing package.el before installing packages
;; via use-package because first I have to get "use-package" itself.
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
(setq use-package-always-pin "melpa-stable")
(use-package cider) ;; even with :pin "melpa-stable" it doesn't work
;; Then `ls ~/.emacs.d/elpa` -> cider is from melpa.org, not stable.melpa.org.
Any ideas?
Thanks.
I've been annoyed by the package pin feature for various reasons, but just found this:
Note that package-pinned-packages must be set before calling package-refresh-contents because the pinning is evaluated while building the package index, and not when installing packages.
This is certainly not user friendly, but this may be your problem.
@jwiegley What do you think the best solution to fix :pin is? I imagine that calling package-refresh-contents after each :pin would be terrible.
I don't use any of the :ensure logic, so I have no idea what the right answer here would be.
Yeah, :pin is kind of useless atm for the reasons that @fice-t states. I just set my pin packages before any package-initialize has a chance to run instead.
@thomasf I eventually did the same thing + got rid of :ensure.
we've been bitten by this in http://ensime.github.io/editors/emacs/install/#installing
The following change makes :pin functional for me when used with :ensure. If as @fice-t says,
calling package-refresh-contents after each :pin would be terrible.
Perhaps we could get away with package-read-all-archive-contents in most circumstances to avoid any unnecessary Internet access.
(defun use-package-ensure-elpa (package &optional no-refresh)
(if (package-installed-p package)
t
(if (or (and (assoc package package-archive-contents) (not (assoc package package-pinned-packages)))
no-refresh)
(package-install package)
(progn
(package-refresh-contents)
(use-package-ensure-elpa package t)))))
Any planned solution for this so far?
@Alexander-Shukaev Looking at the current use-package-ensure-elpa (https://github.com/jwiegley/use-package/blob/master/use-package.el#L731), this should be resolved now. Please confirm?
Most helpful comment
I've been annoyed by the package pin feature for various reasons, but just found this:
This is certainly not user friendly, but this may be your problem.
@jwiegley What do you think the best solution to fix
:pinis? I imagine that callingpackage-refresh-contentsafter each:pinwould be terrible.