Why does my Mac (OS X 10.7.3) have an old version (2.3) of Gnu Bison?
Asked Answered
H

7

14

The version of GNU Bison on my mac is 2.3 but I know that Bison 2.5 was released long ago. The book Flex & Bison uses version 2.5.

Should I upgrade to 2.5 myself? Is it necessary?

What's the difference between 2.3 and 2.5?

Hg answered 28/5, 2012 at 3:1 Comment(1)
You should really be looking to GNU's page on Bison for that information.Absorptivity
B
7

If you use Brew:

brew tap homebrew/dupes && brew install bison

If you use MacPorts:

sudo port install bison

If you use Fink, they're still on 2.3, just like Apple, so you'll have to edit the package yourself.

If you know how to install Unix software, download it, untar, then configure/make/install as usual.

If all of the above are Greek to you, look at Link and http://macports.org and decide which one looks friendlier to you.

Bastien answered 30/5, 2012 at 1:6 Comment(1)
For the "what is different between 2.3 and 2.5" part, see Michael Petrotta's comment to the main question.Bastien
S
21

I had the same issue MacOSX 10.9.5.

After doing:

brew install bison

I added this to my bash profile:

export PATH=/usr/local/Cellar/bison/3.0.4/bin:$PATH

(by the time you read this, your version may be different from 3.0.4) And after I restarted the Terminal it picked up the new version of Bison when I did bison -V

Stone answered 24/9, 2015 at 5:30 Comment(1)
any idea why we need to have such an explicit path?Gizmo
B
19

If you are using zsh:

$ brew unlink bison
$ echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.zshrc
$ export LDFLAGS="-L/usr/local/opt/bison/lib"
$ source ~/.zshrc
$ bison -V
bison (GNU Bison) 3.4.1
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Berryman answered 9/6, 2019 at 8:46 Comment(2)
Works great on CatalinaAutomaton
Works on Big Sur!Metic
V
13

you can install a new version with homebrew:

$ brew install bison

...

This formula is keg-only, which means it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

Some formulae require a newer version of bison.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/bison/lib

==> Summary
🍺  /usr/local/Cellar/bison/3.0.4: 51 files, 2.2M, built in 74 seconds

But if you run: bison -V, it will still output 2.3, not the newly install 3.0.4. To enforce this, you can run this:

arganzhengs-MacBook-Pro:thrift argan$ brew unlink bison
Unlinking /usr/local/Cellar/bison/3.0.4... 0 symlinks removed
arganzhengs-MacBook-Pro:thrift argan$ brew link bison
Warning: bison is keg-only and must be linked with --force
Note that doing so can interfere with building software.
arganzhengs-MacBook-Pro:thrift argan$ brew link bison --force
Linking /usr/local/Cellar/bison/3.0.4... 9 symlinks created
arganzhengs-MacBook-Pro:thrift argan$ bison -V
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
arganzhengs-MacBook-Pro:thrift argan$ source ~/.bash_profile 
arganzhengs-MacBook-Pro:thrift argan$ bison -V
bison (GNU Bison) 3.0.4
Written by Robert Corbett and Richard Stallman.
Voltmer answered 15/6, 2015 at 11:58 Comment(0)
B
7

If you use Brew:

brew tap homebrew/dupes && brew install bison

If you use MacPorts:

sudo port install bison

If you use Fink, they're still on 2.3, just like Apple, so you'll have to edit the package yourself.

If you know how to install Unix software, download it, untar, then configure/make/install as usual.

If all of the above are Greek to you, look at Link and http://macports.org and decide which one looks friendlier to you.

Bastien answered 30/5, 2012 at 1:6 Comment(1)
For the "what is different between 2.3 and 2.5" part, see Michael Petrotta's comment to the main question.Bastien
D
5

So I figured out how to get rid of bison build issues on Mojave and Catalina.

Here's what I did:

$ brew install bison
$ cp /usr/local/opt/bison/bin/bison /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/bison

--

Didn't need admin privileges, the cp command will overwrite the bison binary in your Xcode app with the latest one installed by homebrew.

now I can do this:

    $ bison -V
bison (GNU Bison) 3.7.1

Been having so many problems building wine on multiple macOS systems running Mojave. Mostly due to this weird need for a library I've never heard of, but this fix got it working.

Diamond answered 10/8, 2020 at 4:36 Comment(1)
Is it really a wise idea to overwrite the system version of bison like this? Is it not a risk for system stability?Andesite
V
0

I used Brew and installed the package. However, this does not update the location of bison. I still see bison 2.3 instead of 2.5.

Then, I found that the location of new bison is different.

bash-3.2$ echo $PATH
/opt/local/bin:/opt/local/sbin:/Users/taposh/anaconda/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/m4/bin/
bash-3.2$ PATH=/usr/local/bison/bin/:$PATH
bash-3.2$ which bison
/usr/local/bison/bin//bison

bash-3.2$ bison --version
bison (GNU Bison) 2.5
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Voidance answered 2/2, 2015 at 18:28 Comment(0)
S
0

Because bison was been installed,the default version on osx is 2.3. So we should do something as follow:

  1. Install a higher version os bison

    If you use Brew, try to use this command--brew install bison, it will install bison 3.0.2. The binary package is under /usr/local/Cellar/bison/3.0.4/bin/ in my computer.

    Or you can install bison through source code, follow instructions on offical website http://www.gnu.org/software/bison/.

  2. Replace the old one(you need sudo or root permission)

    $ which bison --- find the installed path,in my computer it's /usr/bin/bison

    $ cd /usr/bin

    $ sudo mv bison bison.2.3

    $ sudo cp /usr/local/Cellar/bison/3.0.4/bin/bison bison

Then you can install thrift without this problem.

Squinty answered 26/1, 2016 at 16:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.