【问题标题】:Bison latest version installed but not in useBison 最新版本已安装但未使用
【发布时间】:2014-07-18 23:17:07
【问题描述】:
$ 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 版本更改为它安装的版本。

$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

【问题讨论】:

  • 似乎是路径问题.. echo $PATH 的输出是什么?
  • 好吧..据我所知:/usr/local/bin 之前的路径中有 /opt/local/bin。 Homebrew 默认安装在 /usr/local/bin 中,所以你可能在 /opt/local/bin 中有另一个版本,首先找到。
  • 我在 /opt/local/bin 里确实有一只野牛!谢谢!您介意将您的评论移至回答以便我接受吗?
  • 移到回答..谢谢;)

标签: package homebrew bison


【解决方案1】:

我刚刚遇到了同样的问题 - 在我的情况下 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

【讨论】:

  • 在较新版本的 Homebrew 中,警告后的输出建议执行以下操作,而不是与 --force 链接:“如果您需要先在 PATH 中安装此软件,请考虑运行:echo 'export PATH="/opt/homebrew/opt/bison/bin:$PATH"' >> ~/.zshrc "。
【解决方案2】:

/usr/local/bin 之前的路径中有 /opt/local/bin。 Homebrew 默认安装在 /usr/local/bin 中,所以你可能在 /opt/local/bin 中有另一个版本,首先找到。

【讨论】:

    【解决方案3】:
    $ 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
    

    【讨论】:

      【解决方案4】:

      感谢安德鲁的回答。 稍微改进一下,不需要--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补丁,在source ~/.zshrc之后,野牛是最新版本(使用brew install bison版本)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-16
        • 2014-12-09
        • 1970-01-01
        • 1970-01-01
        • 2013-05-02
        相关资源
        最近更新 更多