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

Can't install thrift gem on OS X El Capitan

在 OSX El Capitan 升级后尝试安装盗贼 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]

我有办法给你!希望。

前几天遇到了同样的问题。

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

尝试运行以下命令,让我知道结果如何!

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

你需要转义双引号。

$ 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"

试试这个

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

Big Surhttps://github.com/instructure/canvas-lms/issues/827#issuecomment-946388555

有帮助
gem install thrift -v 0.15.0 -- --with-cppflags="-Wno-compound-token-split-by-macro"

这对我有用 mac bigsur

gem install thrift -v '0.10.0.0' -- --with-cppflags="-D_FORTIFY_SOURCE=0 -Wno-shift-negative-value -Wno-compound-token-split-by-macro"