List of installed packages and versions
How can I find out the version of a package I have installed with straight.el?
Is there a way i can find a list of installed packages and their version numbers (where that makes sense)?
How can I find out the version of a package I have installed with straight.el?
I have the following in my init file.
;; Inspired by `magit-version'
(defun chunyang-straight-git-version (package)
(interactive
(list
(straight--select-package "Package" nil 'installed)))
(let ((recipe (gethash package straight--recipe-cache))
version)
(straight--with-plist recipe
(local-repo type)
(when (and (eq type 'git) local-repo)
(let ((default-directory (straight--repos-dir local-repo)))
(setq version (or (magit-git-string "describe" "--tags" "--dirty")
(magit-rev-parse "--short" "HEAD")))
(message "%s %s" (upcase-initials package) version)
version)))))
(chunyang-straight-git-version "magit")
=> "2.11.0-584-g4eb84d44"
Is there a way i can find a list of installed packages and their version numbers (where that makes sense)?
(map-keys straight--recipe-cache)
(let ((magit-repository-directories
(list (cons (straight--repos-dir) 1))))
(magit-list-repositories))
Yes, I like the above suggestions. (Using M-x straight-freeze-versions may also be an option, depending on what you want.) It would be a good idea to add an interactive command for this, contributions welcome.
Wonderful, thanks @xuchunyang. That solution works great.
I would have no objection to adding these kinds of quick hacks to straight-x.el, by the way. That way people could use them even more easily. (And we can get rid of them once there is a suitable replacement in straight.el proper.)
Perhaps the name should be straight-contrib.el rather than straight-x.el? (I'm not sure.)
I wanted to give this issue a bump - @xuchunyang 's solution works nicely, but it would be a nice feature to have a function straight-list-all-package-versions or so, which e.g. opens a buffer and prints all installed packages with their respective versions in a list or a table or so :)
Pull requests are always appreciated.
internal api have changed so far, so xuchungyang's function need to be adjusted:
(defun straight-package-version (package)
(interactive
(list
(straight--select-package "Package" #'straight--installed-p)))
(let ((recipe (gethash package straight--recipe-cache))
version)
(straight--with-plist recipe
(local-repo type)
(when (and (eq type 'git) local-repo)
(let ((default-directory (straight--repos-dir local-repo)))
(setq version (or (magit-git-string "describe" "--tags" "--dirty")
(magit-rev-parse "--short" "HEAD")))
(message "%s %s" (upcase-initials package) version)
version)))))