9

When I do M-x package-install RET magit it installs the latest version of magit which is 2.1.0.

I want to install magit 1.4.2. I don't want to do it manually by downloading and loading package.

For example, if I am downloading a python package, I can specify version number while installing.

pip install django==1.8

How can I do something like that and install magit=1.4.2?

3
  • 1
    AFAIK, Melpa doesn't deal in official releases, and you're not actually getting version 2.1.0 -- you're getting the latest (maybe unstable) code from the source repository, which will probably refer to itself as 2.1.0 if there hasn't been a subsequent official release, but which isn't the same code as that official version. Use a different package repository if you want official releases (try Marmalade or Melpa-Stable).
    – phils
    Jul 27, 2015 at 4:52
  • @phils Is there a way to install an old release from melpa stable? Jul 27, 2015 at 4:59
  • I'm not seeing an obvious way, I'm afraid. In this scenario, the maintainer might have to register a second package (e.g. magit-1.x vs magit-2.x). I suspect that you'll have to use an alternative approach for installation. I'm not too familiar with the package manager, though, so someone else may know better.
    – phils
    Jul 27, 2015 at 5:15

4 Answers 4

12

You can't install a previous version of a package in our current infrastructure. Even though Emacs’ built-in package manager now supports multiple versions of a package in recent releases, no popular package archive (i.e. MELPA Stable and Marmalade) actually keeps a backlog of previous releases.

Emacs didn't support this for a long time, and now that it does, the demand for this feature seems to be rather low—as it is generally for versioned releases, considering that MELPA Stable is far less popular than MELPA itself. Notably, none has yet volunteered to work on a backlog of releases for MELPA Stable, and consequently there's little incentive for the maintainers to implement it.

You'll have to download, build and install the package yourself. QUELPA with a custom recipe for Magit will probably help here.

5
  • 4
    Is it still the case, four years later, that it's not possible to install a historical release from MELPA stable? If so, how do people prevent bad MELPA releases from breaking their entire emacs setups across every machine they use?
    – Tom Ellis
    Nov 17, 2019 at 8:15
  • @TomEllis I don't know, but uhm, why don't you find out yourself? It's easy enough isn't it?
    – user227
    Nov 18, 2019 at 9:14
  • 3
    I'm not sure I understand. This is a question and answer site and I'm asking if the question originally asked has a new answer (and giving a rationale for why one might want a new answer). How would you suggest I find out for myself, short of asking here?
    – Tom Ellis
    Nov 18, 2019 at 10:48
  • @TomEllis No offence meant, but you can really just check the package archive contents of MELPA yourself, e.g. via M-x list-packages in Emacs. If you find that my answer needs an update, feel free to propose an edit afterwards.
    – user227
    Nov 18, 2019 at 14:22
  • 1
    @TomEllis The elpa website: elpa.gnu.org now lists the older versions for each package. You can download an archive and use package-install-file to install it.
    – subhacom
    May 12, 2022 at 5:49
7

You can use el-get to install any specific revision of any package, from a git repo.

(el-get-bundle git-timemachine
  :checkout "3.0")

This will clone git-timemachine from github and checkout tag 3.0 and require git-timemachine.

2
  • Is this feature still supported? I tried to install a previous version of magit (their current version does not support emacs 24 anymore) by running the following: (el-get-bundle! magit :checkout "2.90.0") in scratch buffer, and only got error messages (error "El-get can not find a recipe for package \"package\"")
    – menuhin
    Jun 8, 2018 at 16:21
  • It works without the exclamation mark: (el-get-bundle magit :checkout "2.90.0") Please amend your answer. Thanks.
    – menuhin
    Jun 8, 2018 at 16:26
2

Update as of 2022, elpa lists the older versions of a package on its page. One can download the archive file and then use package-install-file command on emacs to install this specific version.

I could not find a way to directly install a specific version, and even with the above approach, it is not clear if the versions of the dependencies are handled properly.

0

This problem was solved ages ago. I saw the implemention in Steve Purcell's emacs.d about ten years ago.

The solution uses only Emacs built in package system.

Once it's set up, you don't need manually run M-x package-install-file from time to time. It won't change your daily workflow to install/upgrade packages.

Step 1, create a local package repository containing old version of packages.

Add file archive-contents and "magit-1.4.2.tar" into ~/.emacs.d/localelpa, archive-contents is like,

(1
  (magit . [(1 4 2) nil "blah blah" tar])
) 

Step 2, add below content into ~/.emacs.d/init.el,

(push (cons "localelpa" "~/.emacs.d/localelpa/") package-archives)
(defun my-package--add-to-archive-contents-hack (orig-func &rest args)
  (let* ((package (nth 0 args))
         (archive (nth 1 args))
         (pkg-name (car package))
         ;; (version (package--ac-desc-version (cdr package)))
         (add-to-p (or (string= archive "localelpa")
                       (not (string-match-p "^magit" (format "%s" pkg-name))))))
    (if add-to-p (apply orig-func args))))
(advice-add 'package--add-to-archive-contents :around #'my-package--add-to-archive-contents-hack)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.