16
$ brew install bison
Warning: bison-3.0.2 already installed
$ bison -V
bison (GNU Bison) 2.3

How can I change the Bison version in use to 3.0.2? I'm on OS X 10.9.4. I've restarted my terminal after $brew install bison.

UPDATE

I'm really not sure if this is a problem of HomeBrew or Bison. I reinstalled Bison with MacPorts:

$port install bison
......
$bison -V
bison (GNU Bison) 2.7.12-4996

MacPorts did not install the latest version of Bison, but it did change the Bison version in use to the one it installed.

UPDATE ON $PATH

$echo $PATH
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/Users/my_user_name/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/munki:/usr/local/mysql/bin:/Users/my_user_name/code/bin:/Users/my_user_name/code/bin/git:/Users/my_user_name/code/bin/old_git:/Users/my_user_name/code/bin:/Users/my_user_name/code/bin/git:/Users/my_user_name/code/bin/old_git:/Users/my_user_name/.rvm/bin
goldfrapp04
  • 2,326
  • 7
  • 34
  • 46
  • seems like a path problem.. what is the output of `echo $PATH`? – rje Jul 18 '14 at 23:33
  • well.. as far as I can see: you have /opt/local/bin in your path before /usr/local/bin. Homebrew installs in /usr/local/bin by default so maybe you have another version in /opt/local/bin that gets found first. – rje Jul 18 '14 at 23:51
  • I do have a bison in /opt/local/bin! Thanks! Do you mind moving your comment to answer so that I can accept it? – goldfrapp04 Jul 18 '14 at 23:56
  • moved to answer.. thanks ;) – rje Jul 18 '14 at 23:57

4 Answers4

48

I just ran into the same issue - in my case brew wasn't creating the symlinks. You can force this in order to get the right version via:

$ brew unlink bison
Unlinking /usr/local/Cellar/bison/3.0.4... 0 symlinks removed

$ brew link bison
Warning: bison is keg-only and must be linked with --force
Note that doing so can interfere with building software.

$ brew link bison --force
Linking /usr/local/Cellar/bison/3.0.4... 9 symlinks created

$ source ~/.bash_profile
$ bison -V
bison (GNU Bison) 3.0.4
Andrew
  • 1,038
  • 11
  • 14
  • In newer versions of Homebrew, the output after the warning recommends doing the following instead of linking with `--force`: "If you need to have this software first in your PATH instead consider running: `echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.zshrc`". – Sébastien Lavoie Dec 16 '21 at 20:05
9

You have /opt/local/bin in your path before /usr/local/bin. Homebrew installs in /usr/local/bin by default so maybe you have another version in /opt/local/bin that gets found first.

rje
  • 6,388
  • 1
  • 21
  • 40
  • The path was the issue for me as well. But I found the brew installed bison in `/usr/local/opt` – lenz Apr 12 '22 at 19:33
6
$ brew unlink bison
Unlinking /usr/local/Cellar/bison/3.4... 0 symlinks removed

$ brew install bison

$ brew link bison --force
Linking /usr/local/Cellar/bison/3.4... 9 symlinks created

$ echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile

$ export LDFLAGS="-L/usr/local/opt/bison/lib"

$ source ~/.bash_profile
$ bison -V
bison (GNU Bison) 3.4
Prakhar Agarwal
  • 2,724
  • 28
  • 31
4

thanks for Andrew's answer. Just a little improvement, do not need --force

brew link bison
Warning: bison is keg-only and must be linked with --force
Note that doing so can interfere with building software.
If you need to have this software first in your PATH instead consider 
running:
   echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc

I use the suggested echo patch to zshrc, after

source ~/.zshrc

the bison was the newest version(use brew install bison version).

MGY
  • 7,245
  • 5
  • 41
  • 74
jayzhou215
  • 111
  • 1
  • 3