From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Andrew Childs <lorne@cons.org.nz>
Cc: 16994-done@debbugs.gnu.org
Subject: bug#16994: 24.3; package.el dependency ordering incorrect (non-topological)
Date: Tue, 06 May 2014 14:13:45 -0400 [thread overview]
Message-ID: <jwvvbtiixvo.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <86ha742hy7.fsf@northind.cons.org.nz> (Andrew Childs's message of "Wed, 12 Mar 2014 16:50:56 +1300")
> package.el does not resolve dependencies in the correct order,
> potentially resulting in packages installed before their
> dependencies. This was reported in #14082 [1], but not fixed for all
> cases. The packages should be arranged in topological order before
> installation.
Indeed, thanks. I installed the patch below which should make the sort
truly topological. It also adds detection of dependency cycles since
this new topological sorting would otherwise get into an inf-loop
in that case.
Stefan
=== modified file 'lisp/emacs-lisp/package.el'
--- lisp/emacs-lisp/package.el 2014-03-28 22:47:46 +0000
+++ lisp/emacs-lisp/package.el 2014-05-06 18:07:45 +0000
@@ -868,7 +868,7 @@
;; Also check built-in packages.
(package-built-in-p package min-version)))
-(defun package-compute-transaction (packages requirements)
+(defun package-compute-transaction (packages requirements &optional seen)
"Return a list of packages to be installed, including PACKAGES.
PACKAGES should be a list of `package-desc'.
@@ -880,7 +880,9 @@
This function recursively computes the requirements of the
packages in REQUIREMENTS, and returns a list of all the packages
that must be installed. Packages that are already installed are
-not included in this list."
+not included in this list.
+
+SEEN is used internally to detect infinite recursion."
;; FIXME: We really should use backtracking to explore the whole
;; search space (e.g. if foo require bar-1.3, and bar-1.4 requires toto-1.1
;; whereas bar-1.3 requires toto-1.0 and the user has put a hold on toto-1.0:
@@ -893,15 +895,22 @@
(dolist (pkg packages)
(if (eq next-pkg (package-desc-name pkg))
(setq already pkg)))
- (cond
- (already
+ (when already
(if (version-list-<= next-version (package-desc-version already))
- ;; Move to front, so it gets installed early enough (bug#14082).
- (setq packages (cons already (delq already packages)))
+ ;; `next-pkg' is already in `packages', but its position there
+ ;; means it might be installed too late: remove it from there, so
+ ;; we re-add it (along with its dependencies) at an earlier place
+ ;; below (bug#16994).
+ (if (memq already seen) ;Avoid inf-loop on dependency cycles.
+ (message "Dependency cycle going through %S"
+ (package-desc-full-name already))
+ (setq packages (delq already packages))
+ (setq already nil))
(error "Need package `%s-%s', but only %s is being installed"
next-pkg (package-version-join next-version)
(package-version-join (package-desc-version already)))))
-
+ (cond
+ (already nil)
((package-installed-p next-pkg next-version) nil)
(t
@@ -933,12 +942,13 @@
(t (setq found pkg-desc)))))
(unless found
(if problem
- (error problem)
+ (error "%s" problem)
(error "Package `%s-%s' is unavailable"
next-pkg (package-version-join next-version))))
(setq packages
(package-compute-transaction (cons found packages)
- (package-desc-reqs found))))))))
+ (package-desc-reqs found)
+ (cons found seen))))))))
packages)
(defun package-read-from-string (str)
prev parent reply other threads:[~2014-05-06 18:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 3:50 bug#16994: 24.3; package.el dependency ordering incorrect (non-topological) Andrew Childs
2014-05-06 18:13 ` Stefan Monnier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvvbtiixvo.fsf-monnier+emacsbugs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=16994-done@debbugs.gnu.org \
--cc=lorne@cons.org.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.