$ brew install bison
Warning: bison-3.0.2 already installed
$ bison -V
bison (GNU Bison) 2.3
如何将使用的Bison版本更改为3.0.2?我在OS X 10.9.4上。我在$brew install bison
之后重启了我的终端。
更新
我真的不确定这是HomeBrew还是Bison的问题。我用MacPorts重新安装了Bison:
$port install bison
......
$bison -V
bison (GNU Bison) 2.7.12-4996
MacPorts没有安装最新版本的Bison,但它确实将正在使用的Bison版本更改为它安装的版本。
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
答案 0 :(得分:34)
我刚遇到同样的问题 - 在我的情况下,brew并没有创建符号链接。 您可以强制执行此操作以通过以下方式获取正确的版本:
$ 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
答案 1 :(得分:4)
/ usr / local / bin之前的路径中有/ opt / local / bin。默认情况下,Homebrew会安装在/ usr / local / bin中,所以你可能会先在/ opt / local / bin中找到另一个版本。
答案 2 :(得分:0)
感谢Andrew回答。 稍微改进一下,不需要--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
我在zshrc中使用了建议echo补丁,在源〜/ .zshrc之后,bison是最新版本(使用brew install bison版本)。
答案 3 :(得分:0)
$ 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