无法在OS X El Capitan上安装thrift gem

时间:2016-04-02 20:10:38

标签: ruby rubygems thrift

尝试在OSX El Capitan升级后安装thift gem:

    $ gem install thrift
    Building native extensions.  This could take a while...
    ERROR:  Error installing thrift:
        ERROR: Failed to build gem native extension.

        /Users/foo/.rvm/rubies/ruby-2.1.4/bin/ruby -r ./siteconf20160402-32256-7dzqel.rb extconf.rb
    checking for strlcpy() in string.h... yes
    creating Makefile

    make "DESTDIR=" clean

    make "DESTDIR="
    compiling binary_protocol_accelerated.c
    compiling bytes.c
    compiling compact_protocol.c
    compact_protocol.c:442:41: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
        rb_exc_raise(get_protocol_exception(INT2FIX(-1), rb_str_new2(buf)));
                                            ^~~~~~~~~~~

编译失败 compact_protocol.c:442:41:错误:移位负符号值未定义[-Werror,-Wshift-negative-value]

3 个答案:

答案 0 :(得分:58)

我有一个解决方案给你!希望。

前几天有同样的问题。

问题出在El Capitan捆绑的clang编译器中。我确定它搞砸了其他问题,但这是我遇到很多问题的一点。

尝试运行以下命令,让我知道它是怎么回事!

gem install thrift -- --with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-shift-negative-value\"

答案 1 :(得分:17)

你需要逃避双引号。

  

$ bundle config build.thrift“--with-cppflags = \” - D_FORTIFY_SOURCE = 0 -Wno-shift-negative-value \“”

     

$ cat~ / .bundle / config

     

BUNDLE_BUILD__THRIFT: - with-cppflags =“ - D_FORTIFY_SOURCE = 0 -Wno-shift-negative-value”

答案 2 :(得分:-1)

试试这个

gem install thrift -v '0.9.0' -- --with-cppflags='-D_FORTIFY_SOURCE=0'