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

Ant*_*ton 20 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)));
                                            ^~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)

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

non*_*ame 61

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

前几天有同样的问题.

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

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

gem install thrift -- --with-cppflags=\"-D_FORTIFY_SOURCE=0 -Wno-shift-negative-value\"
Run Code Online (Sandbox Code Playgroud)

  • 这适用于 gem 安装,但捆绑安装不起作用。我尝试了 `bundle config build.thrift "--with-cppflags=-D_FORTIFY_SOURCE=0"` 但这不起作用,关于如何解决捆绑配置中的 -Wno-shift-负值 选项有什么想法吗? (2认同)

小智 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"


小智 9

大苏尔 有帮助https://github.com/instruct/canvas-lms/issues/827#issuecomment-946388555

gem install thrift -v 0.15.0 -- --with-cppflags="-Wno-compound-token-split-by-macro"
Run Code Online (Sandbox Code Playgroud)