Homebrew/homebrew — pull request #27268 by iainbeeston (2014-03-06 16:32:56+00:00)
Title: Installing an outdated version should show a warning, not an error

Problem
-----------

I'd like to use the `brew bundle` command, but it has an annoying bug.

If you have a Brewfile like this:

```
install redis
install mysql
```

and you already have redis-2.8.1 installed, but the latest version is redis-2.8.7, then running `brew bundle` will fail like so:

```
Error: redis-2.8.1 already installed
To install this version, first `brew unlink redis'
Error: Command failed: L4:brew install redis
```

There are two problems with this:

1. The error message is unhelpful (there is no explanation of why redis being installed is an error - surely that should be a good thing?)
2. Any commands after the error are not executed

If you do already have redis-2.8.7 installed, the output is this:

```
Warning: redis-2.8.7 already installed
```

But at least mysql gets installed.

Solution
-----------

Digging into the code, the `bundle` command exits if any commands in the Brewfile fail. I believe that if the package is already installed, then install should not be failing at all (maybe outputting a warning like it does when the latest version is installed, but not failing).

To make it behave like this, I have added a new error class, to be used when an outdated version is installed. This is treated the same as when the latest version is installed, but shows a different (and more helpful) warning message.

With this patch my example above produces the following output:

```
Warning: redis-2.8.1 installed but redis-2.8.7 is the latest
To install the latest version, first `brew unlink redis'
```

and the mysql formula is installed successfully.