Active11 months ago
If you do not uninstall all of the versions that Homebrew has installed, Homebrew will continue to attempt to install the newest version it knows about when you run brew upgrade. This can be surprising. To remove a formula entirely, you may run brew uninstall --force. Be careful as this is a destructive operation. This output also lets you know which version is the default and which one is the current one in use. To use a specific version (2.2.0 in the example below) and also set it as the default version for new shell sessions: rvm use 2.2.0 --default To verify: ruby -v The version should match that of the current Ruby in use. Troubleshooting Homebrew.
I need to install python3.4 on my OS X. Tried to do it with
brew install python3
and now I have python 3.5.1. But I need py3.4.How can I install python3.4 on my Mac?
PaulPaul
4 Answers
I have done this sort of thing in two ways - however both do not coexist with homebrew although I suspect there should be a way similar to the macports one.
The first is using Macports as the package manager. There are separate ports for several python versions 2.x and 3.x currently 2.4, 2.5, 2.6, 2.7 and 3.1, 3.2, 3.3 3.4 and 3.5. For example to install 3.4 do
Each package manager needs to run as the only package manager otherwise it will be confused with unexpected different versions of libraries and executables on its paths.
sudo port install python34
There is also a python_select port that running it allows you to choose which version of python is run by /opt/bin/python.Each package manager needs to run as the only package manager otherwise it will be confused with unexpected different versions of libraries and executables on its paths.
The other way is install direct from python.org This will install a python into /usr/local/bin I think this installs a python and python3 executable. The issue with Homebrew is that it assumes that things in /usr/local are installed by it and so brew doctor will report these python.org pythons and libraries as issues and as this question shows also the frameworks in /Library will be problematic.
EDIT 8/2018 *** I would now suggest using conda either miniconda or anaconda. This is another package manager but based and mainly meant for python, it also gives the equivalent of python's virtual environments and pyenv (as per other answer) and so each project can be in a different python and different libraries (Macports only switches python version for all projects)
MarkMark21k1212 gold badges6060 silver badges9898 bronze badges
$ brew install python3
is equals follow$ brew install https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
So. if you want to install a specific version then, you must check before install.
- Check the git history of python.rb
- Find the version you want. Now you can use
brew install
with the corresponding commit hash:- 3.4.3_2:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/bd43f59bd50bb49242259f327cb6ac7a8dd59478/Formula/python3.rb
- 3.5.2_3:
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/ec545d45d4512ace3570782283df4ecda6bb0044/Formula/python3.rb
- 3.6.5_1:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
- 3.4.3_2:
There is also: https://github.com/sashkab/homebrew-python where you can install using
brew install sashkab/python/python34
and brew link python34 --force
Please note that python3.rb was renamed to python.rb at some point. Change the URL if necessary.
JayJay
For python in mac use pyenv
To select a version
To List versions
You need to export the PATH to override the default python version.
nohillside♦57.1k1414 gold badges120120 silver badges168168 bronze badges
Knight71Knight71
This seems like a much easier approach AND keeps away from /usr/local/bin !!
I haven't tested it, but it promises to be able to install any version (and multiple versions) of Python.
Including 3.6.6 which isn't available in the brew core as far as I can tell.
BrendanSimonBrendanSimon
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged homebrewpython .
Active2 months ago
How do I install a specific version of a formula in homebrew? For example, postgresql-8.4.4 instead of the latest 9.0.
Jay P.3,67344 gold badges3838 silver badges6868 bronze badges
GravisGravis11.3k44 gold badges1717 silver badges1717 bronze badges
24 Answers
TLDR:
brew install [email protected]
See answer below for more details.*(I’ve re-edited my answer to give a more thorough workflow for installing/using older software versions with homebrew. Feel free to add a note if you found the old version better.)
Let’s start with the simplest case:
1) Check, whether the version is already installed (but not activated)
When homebrew installs a new formula, it puts it in a versioned directory like
/usr/local/Cellar/postgresql/9.3.1
. Only symbolic links to this folder are then installed globally. In principle, this makes it pretty easy to switch between two installed versions. (*)If you have been using homebrew for longer and never removed older versions (using, for example
brew cleanup
), chances are that some older version of your program may still be around. If you want to simply activate that previous version, brew switch
is the easiest way to do this.Check with
brew info postgresql
(or brew switch postgresql <TAB>
) whether the older version is installed:We see that some older version is already installed. We may activate it using
brew switch
:Let’s double-check what is activated:
Note that the star
*
has moved to the newly activated version(*) Please note that
brew switch
only works as long as all dependencies of the older version are still around. In some cases, a rebuild of the older version may become necessary. Therefore, using brew switch
is mostly useful when one wants to switch between two versions not too far apart.2) Check, whether the version is available as a tap
Especially for larger software projects, it is very probably that there is a high enough demand for several (potentially API incompatible) major versions of a certain piece of software. As of March 2012, Homebrew 0.9 provides a mechanism for this:
brew tap
& the homebrew versions repository.That versions repository may include backports of older versions for several formulae. (Mostly only the large and famous ones, but of course they’ll also have several formulae for postgresql.)
brew search postgresql
will show you where to look:We can simply install it by typing
Note that this has automatically tapped the
homebrew/versions
tap. (Check with brew tap
, remove with brew untap homebrew/versions
.) The following would have been equivalent:As long as the backported version formulae stay up-to-date, this approach is probably the best way to deal with older software.
3) Try some formula from the past
The following approaches are listed mostly for completeness. Both try to resurrect some undead formula from the brew repository. Due to changed dependencies, API changes in the formula spec or simply a change in the download URL, things may or may not work.
Since the whole formula directory is a git repository, one can install specific versions using plain git commands. However, we need to find a way to get to a commit where the old version was available.
a) historic times
Between August 2011 and October 2014, homebrew had a
brew versions
command, which spat out all available versions with their respective SHA hashes. As of October 2014, you have to do a brew tap homebrew/boneyard
before you can use it. As the name of the tap suggests, you should probably only do this as a last resort.E.g.
As you can see, it advises against using it. Homebrew spits out all versions it can find with its internal heuristic and shows you a way to retrieve the old formulae. Let’s try it.
Now that the older postgresql version is installed, we can re-install the latest formula in order to keep our repository clean:
brew switch
is your friend to change between the old and the new.b) prehistoric times
For special needs, we may also try our own digging through the homebrew repo.
git log -S
looks for all commits in which the string '8.4.4'
was either added or removed in the file Library/Taps/homebrew/homebrew-core/Formula/postgresql.rb
. We get two commits as a result.Obviously,
fa992c6a82eebdc4cc36a0c0d2837f4c02f3f422
is the commit we’re interested in. As this commit is pretty old, we’ll try to downgrade the complete homebrew installation (that way, the formula API is more or less guaranteed to be valid):You may skip the last command to keep the reference in your git repository.
One note: When checking out the older commit, you temporarily downgrade your homebrew installation. So, you should be careful as some commands in homebrew might be different to the most recent version.
4) Manually write a formula
It’s not too hard and you may then upload it to your own repository. Used to be Homebrew-Versions, but that is now discontinued.
A.) Bonus: Pinning
If you want to keep a certain version of, say postgresql, around and stop it from being updated when you do the natural
brew update; brew upgrade
procedure, you can pin a formula:Pinned formulae are listed in
laurent/usr/local/Library/PinnedKegs/
and once you want to bring in the latest changes and updates, you can unpin it again:55.6k5656 gold badges211211 silver badges339339 bronze badges
DebilskiDebilski56.3k88 gold badges101101 silver badges130130 bronze badges
Now that Homebrew/versions has been deprecated, Homebrew/core supports multiple versions of formulae with a new naming format.
To install a specific version, e.g. postgresql 9.5 you simply run:
To list the available versions run a search with @:
BijanBijan20.2k55 gold badges6868 silver badges6464 bronze badges
There's now a much easier way to install an older version of a formula that you'd previously installed. Simply use
For instance, I alternate regularly between Node.js 0.4.12 and 0.6.5:
Since
Trevor BurnhamTrevor Burnhambrew switch
just changes the symlinks, it's very fast. See further documentation on the Homebrew Wiki under External Commands.64.2k3030 gold badges146146 silver badges186186 bronze badges
Update: 1/15/2015
- Find the commit history of the desired software and version. e.g. I need to switch from docker version 1.4.1 to 1.3.3: https://github.com/Homebrew/homebrew-core/commits/master/Formula/docker.rb
- View the file with this button:
- Click the Raw button:
- Copy the URL (docker.rb url in this example) from address bar
brew install <url>
(may have tobrew unlink
first, e.g.brew unlink docker
)brew switch docker 1.3.3
- Switch back to docker 1.4.1
brew switch docker 1.4.1
From this gist
alxndr1,93533 gold badges2929 silver badges3131 bronze badges
VishalVishal11.8k1515 gold badges6060 silver badges8484 bronze badges
I've discovered a better alternative solution then the other complex solutions.
This will download and install PostgreSQL 8.4.8
I found this solution by starting to follow the steps of searching the repo and a comment in the repo .
After a little research found that someone has a collection of rare formulars to brew up with.
If your looking for MySQL 5.1.x, give this a try.
Arslan Ali13.9k66 gold badges4040 silver badges6161 bronze badges
halfcubehalfcube3,22611 gold badge2020 silver badges3131 bronze badges
Along the lines of @halfcube's suggestion, this works really well:
- Find the library you're looking for at https://github.com/Homebrew/homebrew-core/tree/master/Formula
- Click it: https://github.com/Homebrew/homebrew-core/blob/master/Formula/postgresql.rb
- Click the 'history' button to look at old commits: https://github.com/Homebrew/homebrew-core/commits/master/Formula/postgresql.rb
- Click the one you want: 'postgresql: update version to 8.4.4', https://github.com/Homebrew/homebrew-core/blob/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb
- Click the 'raw' link: https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8cf29889111b44fd797c01db3cf406b0b14e858c/Formula/postgresql.rb
2,50811 gold badge2828 silver badges4545 bronze badges
Lance PollardLance Pollard33.6k7070 gold badges209209 silver badges359359 bronze badges
You can use the strategy of identifying the formula and a particular commit in the history of the formula that matches the version of the package you'd like to install.
- Go to https://github.com/Homebrew/homebrew-core
- Press
t
on your keyboard to activate the file finder. - Identify a formula that looks most relevant, perhaps:
Formula/mysql.rb
, bringing you to a forumla file location: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb. - Look at the revision history by clicking on the
History
button, which is located at https://github.com/Homebrew/homebrew-core/commits/master/Formula/mysql.rb. If you're interested in MySQL 5.7.10, you might want to click the latest revision prior to 5.7.11, which navigates to a GitHub commit:
NOTE: You may have to view the commit history in your console per GitHub's suggestion if the commit history does not load in your browser. Replace the commit SHA above in the URL if you're interested in seeing that commit on GitHub. Alternatively, skip to step 7, below.
- Click the 'View' button to view the source for the mysql.rb file after the commit was applied.
- Then click the 'Raw' button to view the raw source.
- Copy the URL. Alternatively, build the URL yourself with the
mysql.rb
file name to identify your formula and the particular version of that formula (identified by the commmit SHA in the URL below). - Install it with
$ brew install [URL from step 7]
NOTE: This answer was updated to account for the removal of the braumeister.org website. The same principle applies, braumeister had simply provided a beginner-friendly way to navigate formula versions.
sealocalsealocal
I just used Homebrew to go back to Maven 2.2.1 since the simple
brew install maven
installed Maven 3.0.3.First you have to leave the maven dir there so
Use the brew tap command
Now you can install the maven2 formula:
Edit:You can also just
brew switch maven 2.2.1
to switch to a different version. Edit:The Apache Maven project reorganized their repo. Updated this answer to account for this change.
Cameron GoodaleCameron Goodale
Based on the workflow described by @tschundeee and @Debilski’s update 1, I automated the procedure and added cleanup in this script.
Download it, put it in your path and
brewv <formula_name> <wanted_version>
. For the specific OP, it would be::)
Community♦
MattiSGMattiSG2,63911 gold badge1616 silver badges2828 bronze badges
Most of the other answers are obsolete by now. Unfortunately Homebrew still doesn’t have a builtin way of installing an outdated version, unless that version exists as a separate formula (e.g.
python@2
, [email protected]
…).Luckily, for other formulas there’s a much easier way than the convoluted mess that used to be necessary. Here are the full instructions:
- Search for the correct version in the logs:This will show a list of commit hashes. Take one that is appropriate (mostly it should be pretty obvious, and usually is the most recent (i.e. top) one.
- Find the URL at which the formula resides in the upstream repository:
- Fix the URL:
- Replace
github.com
withraw.githubusercontent.com
- Replace
blob/master
with the commit hash we found in the first step.
- Replace
- Install the desired version by replacing
master
in the previously found URL by the commit hash, e.g.:
(The last step may necessitate running
brew unlink ‹formula›
before.)If you have copied a commit hash you want to use, you can use something like this example to install that version, replacing the value and
bash
with your commit hash and your desired formula.This example is installing bash 4.4.23 instead of bash 5, though if you performed a
brew upgrade
afterward then bash 5 would get installed over top, unless you first executed brew pin bash
. Instead to make this smoother WITHOUT pinning, you should first install the latest with brew install bash
, then brew unlink bash
, then install the older version you want per the script above, and then use brew switch bash 4.4.23
to set up the symlinks to the older version. Now a brew upgrade
shouldn't affect your version of Bash. You can brew switch bash
to get a list of the versions available to switch to.Alternative using a custom local-only tap
Another way of achieving the same goal appears to be:
This creates a
Konrad RudolphKonrad Rudolphformula@version
in your custom tap that you can install per the above example. The downside is that you probably still need to brew unlink bash
and then brew link [email protected]
in order to use your specific version of Bash or any other formula.418k106106 gold badges813813 silver badges10641064 bronze badges
An updated answer since that adds to what @lance-pollard already posted as working answer.
How to Install specific version of a Formula (formula used in this example is
terraform
):- Find your formula file, e.g: https://github.com/Homebrew/homebrew-core/blob/master/Formula/terraform.rb
- Get the commit version from github’s history with https://github.com/Homebrew/homebrew-core/commits/master/Formula/terraform.rb or
git log master -- Formula/terraform.rb
if you have cloned the repo locally. - Get the raw git URL with the commit version of your formula: If the formula link in github.com is https://github.com/Homebrew/homebrew-core/blob/e4ca4d2c41d4c1412994f9f1cb14993be5b2c59a/Formula/terraform.rb, your raw URL will be: https://raw.githubusercontent.com/Homebrew/homebrew-core/e4ca4d2c41d4c1412994f9f1cb14993be5b2c59a/Formula/terraform.rb
- Install it with:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/e4ca4d2c41d4c1412994f9f1cb14993be5b2c59a/Formula/terraform.rb
Miguel ReyesMiguel Reyes
On the newest version of homebrew (0.9.5 as of this writing) there will be a specific recipe for the version of the homebrew keg you want to install. Example:
Then just do
brew install mongodb26
like normal.In the case that you had already installed the latest version, make sure to unlink the latest version and link the desired version:
brew unlink mongodb && brew link mongodb26
.Alex SharpAlex Sharp
The problem with
homebrew/versions
is that someone has to have that specific version of software listed in the repository for you to be able to use it. Also, since brew versions
is no longer supported, another solution is required. For solutions that indicate using brew switch
, this will only work if you haven't done a brew cleanup
since the version needs to exist on your computer.I had a problem with wanting to install a specific older version of
docker-machine
which wasn't listed in homebrew/versions
. I solved this using the below, which should also work for any brew installed software. The example below will use docker-machine
as the package I want to downgrade from version 0.5.0 to 0.4.1.- Go to your homebrew
Formula
directory.
You can determine this by runningbrew info [any package name]
. For example,brew info docker-machine
gives me a line that shows mea path -/usr/local/Cellar/docker-machine/0.5.0
. This tells me that on my machine, homebrew is installed at/usr/local
and myFormula
directory is located by default at/usr/local/Library/Formula
- Locate the specific formula file (.rb) for your package.Since I want to downgrade
docker-machine
, I can see adocker-machine.rb
file. - Get the version history for this formula file . Enter
git log docker-machine.rb
. This will list out the complete commit history for this file. You will see output like this:
The tricky part is to find the latest commit for the specific version you want. In the above, I can tell the latest 0.4.1 version was committed with this commit tag :
commit 5970e1af9b13dcbeffd281ae57c9ab90316ba423
. The commits above this point start using version 0.5.0 (git log entries are listed from latest to earliest date).- Get a previous version of the formula file.Using the commit tag from step #3 (you can use the first 6 chars), you can get an older version of the formula file using the following:
git checkout 5970e1 docker-machine.rb
- Uninstall your current package version.Just run the normal brew commands to uninstall the current version of your package.
Ex.brew uninstall docker-machine
- Install the older package versionNow, you can just run the normal brew install command and it will install the formula that you have checkout out.Ex.
brew install docker-machine
You may need to re-link by using the
brew link docker-machine
if necessary.If at any time you want to revert back to the latest version of a specific package, go into the Formula directory and issue the following commands on your formula file (.rb)
Then you can
brew uninstall docker-machine
and brew install docker-machine
to get the latest version and keep it that way going forward.rchawdryrchawdry
Find your local homebrew git dir or clone Homebrew/homebrew-core locally
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/
OR
git clone [email protected]:Homebrew/homebrew-core.git
List all available versions
git log master -- Formula/flyway.rb
Copy the commit ID for the version you want and install it directly
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/793abfa325531415184e1549836c982b39e89299/Formula/flyway.rb
10.3k11 gold badge3333 silver badges4646 bronze badges
ffghfghffghfgh
I've tried most of the solutions here and they are outdated. I had to combine some ideas from here with my own work. As a result I've created a script to help me do the heavy lifting which you can find here
Usage:
JakeGould21.5k99 gold badges5454 silver badges8080 bronze badges
demostendemosten2,64122 gold badges2020 silver badges1515 bronze badges
it could be done very easy for last version of brew.
Maxim KholyavkinMaxim Kholyavkin2,73611 gold badge2828 silver badges7070 bronze badges
None of these really worked for my case (Python), so I'll add my 2 cents:
Output looks like this:
I want version
2.7.11
so my hash is cf5da0547cd261f79d69e7ff62fdfbd2c2d646e9
(or cf5da05
for short). Next, I check out that version and install the formula python
:Finally, clean up:
tenfishstickstenfishsticks
If you can't find your version with
brew search <formula>
, you can also try going over the commit logs for your formula to find the version you want: here is an example for installing an older version of nginx via brew:
- see
nginx: update 1.6.3 bottle eba75b9a1a474b9fc4df30bd0a32637fa31ec049
From there, we can install
1.6.3
with the sha and raw git url:brew install https://raw.githubusercontent.com/Homebrew/homebrew/eba75b9a1a474b9fc4df30bd0a32637fa31ec049/Library/Formula/nginx.rb
8,3121111 gold badges5353 silver badges9595 bronze badges
lfender6445lfender644518.2k88 gold badges7979 silver badges7171 bronze badges
Official method ( judging from the response to https://github.com/Homebrew/brew/issues/6028 )
Unfortunately Homebrew still doesn’t have an obvious builtin way of installing an older version.
Luckily, for most formulas there’s a much easier way than the convoluted mess that used to be necessary. Here are the full instructions using
bash
as an example:This creates the
formula@version
in your custom tap that you can install per the above example. An important note is that you probably need to brew unlink bash
if you had previously installed the default/latest version of the formula and then brew link [email protected]
in order to use your specific version of Bash (or any other formula where you have latest and an older version installed).A potential downside to this method is you can't easily switch back and forth between the versions because according to
brew
it is a 'different formula'.If you want to be able to use
brew switch $FORMULA $VERSION
you should use the next method.Scripted Method (Recommended)
This example shows installing the older bash 4.4.23, a useful example since the
bash
formula currently installs bash 5.- First install the latest version of the formula with
brew install bash
- then
brew unlink bash
- then install the older version you want per the snippets below
- finally use
brew switch bash 4.4.23
to set up the symlinks to your version
If you performed a
brew upgrade
after installing an older version without installing the latest first, then the latest would get installed clobbering your older version, unless you first executed brew pin bash
.The steps here AVOID pinning because it is easy to forget about and you might pin to a version that becomes insecure in the future (see Shellshock/etc). With this setup a
brew upgrade
shouldn't affect your version of Bash and you can always run brew switch bash
to get a list of the versions available to switch to.Copy and paste and edit the
export
lines from the code snippet below to update with your desired version and formula name, then copy and paste the rest as-is and it will use those variables to do the magic.When you are certain the version exists in the formula, you can use the below:
Once you have exported the commit hash you want to use, you can use this to install that version of the package.
Follow the directions in the formula output to put it into your PATH or set it as your default shell.
dragon788dragon788
Currently the old ways of installing specific formula versions have been deprecated. So it seems like we have to use
brew edit [formula]
. E.g. say we want to install an the 62.1
version of icu4c
(needed e.g. for postgresql 10.5
). Then you'd have to Here you'd have to alter the
url
, version
and sha256
(perhaps also mirror
) to the corresponding 62.1
strings. then run
brew reinstall icu4c
to finally download the 62.1
version.Emil RehhnbergEmil Rehhnberg
Update on the Library/Formula/postgresql.rb line 8 to
And MD5 on line 9 to
Save and exit.
Now in this stage you might face the
postgresql could not create shared memory segment
error, to work around that update the /etc/sysctl.conf
like this:Try
initdb /usr/local/var/postgres
again, and it should run smooth.To run postgresql on start
Hope that helps :)
mmrs151mmrs1512,42422 gold badges2828 silver badges3131 bronze badges
I just copied an older release of elasticsearch into the
/usr/local/Cellar/elasticsearch
directory.That's it.Maybe it's useful for anyone.
Terru_theTerror3,78422 gold badges99 silver badges3030 bronze badges
ThaarsThaars
I decided, against my better judgment, to create a formula for Maven 3.1.1, which
homebrew/versions
did not have. To do this:- I forked
homebrew/versions
on github. - I symlinked from
$(brew --prefix)/Library/Taps
to the local working copy of my fork. I'll call thismy-homebrew/versions
. - I tested by specifying the formula as
my-homebrew/versions/<formula>
. - I sent a pull request to
homebrew/versions
for my new formula.
Yay.
J. B. RainsbergerJ. B. Rainsberger
For versions not currently in the default brew formulas, you can easily create your own tap with the tool from https://github.com/buildtools-version-taps/homebrew-versions-tap-tool
LutziferLutzifer
protected by Samuel Liew♦Oct 5 '15 at 9:19
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?