捆绑安装 Rsruby 失败,但 Gem 安装成功

Bundle Install Rsruby Fails, But Gem Install Succeeds

我有 ruby​​2.2,ubuntu 14.04.4 LTS,我想安装 rsruby gem。一切都已设置,我的所有其他 gems 都已设置,"sudo bundle install." 但是当我尝试这样安装时,rsruby 总是崩溃。我如何调试它并使其工作?

我有一个 运行 脚本 运行 这个命令

sudo bundle config build.rsruby "--with-R-include=/usr/share/R/include --with_cflags=\"-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall -fno-strict-aliasing\""

然后我 运行 "sudo bundle install" 它在 RSRuby 上崩溃了:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby2.2 -r ./siteconf20161028-31919-l2ks0n.rb extconf.rb
--with-R-include=/usr/share/R/include --with_cflags=\"-fPIC -g -O2
-fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall
-fno-strict-aliasing\"
checking for main() in -lR... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.


from /usr/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
from /usr/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
from /usr/lib/ruby/2.2.0/mkmf.rb:735:in `try_func'
from /usr/lib/ruby/2.2.0/mkmf.rb:992:in `block in find_library'
from /usr/lib/ruby/2.2.0/mkmf.rb:911:in `block in checking_for'
from /usr/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /usr/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
from /usr/lib/ruby/2.2.0/mkmf.rb:321:in `open'
from /usr/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
from /usr/lib/ruby/2.2.0/mkmf.rb:910:in `checking_for'
from /usr/lib/ruby/2.2.0/mkmf.rb:988:in `find_library'
from extconf.rb:15:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in
/var/lib/gems/2.2.0/bundler/gems/rsruby-e72a8dc61617 for inspection.
Results logged to
/var/lib/gems/2.2.0/bundler/gems/extensions/x86_64-linux/2.2.0/rsruby-e72a8dc61617/gem_make.out

An error occurred while installing rsruby (0.5.5), and Bundler cannot
continue.

但是如果我 运行

sudo gem install rsruby -- --with-R-dir=/usr/lib/R --with-R-include=/usr/share/R/include --with_cflags="-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall -fno-strict-aliasing"

然后安装成功

Fetching: rsruby-0.5.1.1.gem (100%)
Building native extensions with: '--with-R-dir=/usr/lib/R --with-R-include=/usr/share/R/include --with_cflags=-fPIC -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wall -fno-strict-aliasing'
This could take a while...
Successfully installed rsruby-0.5.1.1
Parsing documentation for rsruby-0.5.1.1
Installing ri documentation for rsruby-0.5.1.1
Done installing documentation for rsruby after 0 seconds
1 gem installed

所以,我的问题是,我该如何调试它?我如何让它与 bundle install 一起工作?谢谢!

更新,正如 matt 在评论中指出的,这两个命令安装的 rsruby gem 版本不同。如果我更改我的 Gemfile 以指定捆绑包以安装版本“0.5.1.1”,则 "sudo bundle install" 安装成功。但是,我需要版本“0.5.5”。我的 Gemfile 目前是这样设置的,"gem 'rsruby', github: 'custora/rsruby'" 并且必须获得版本 0.5.5。那么为什么 0.5.1.1 可以正确安装,而 0.5.5 却不能?

更新,mkmf.log

gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.1.0 -I/usr/include/ruby-2.1.0/ruby/backward -I/usr/include/ruby-2.1.0 -I. -I/usr/share/R/include -D_FORTIFY_SOURCE=2   "-g conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -L/build/ruby2.1-3vrZnx/ruby2.1-2.1.9/debian/lib -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.1  -lpthread -lgmp -ldl -lcrypt -lm   -lc"
sh: 1: Syntax error: Unterminated quoted string
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

好的,这里发生了一些不同的事情。我将把它们全部记录在这里,以防其他需要使用 rsruby 的人遇到这个问题。首先,正如 Matt 指出的那样,bundle install 和 gem install 试图安装两个不同版本的 rsruby。其次,我不得不更改这个我 运行 设置捆绑配置选项的脚本,这个脚本不起作用。为了完成这项工作,我将 \" 替换为 '

#!/bin/bash

# Does /usr/bin/gem link to /usr/bin/gem2.1 ?
# gem install bundler -v 1.6.0.rc2
sudo bundle config build.rsruby "--with-R-include=/usr/share/R/include --with-cflags=\"-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -fPIC\""

以上两步使rsruby安装成功。但在那之后我还是不断收到段错误。问题似乎是 ubuntu 的旧发行版,或者由于它是 ubuntu 的旧发行版,我不得不使用 brightbox repo 来获取更新版本的 [=19] =].无论如何,在更新到具有当前版本 ruby 的当前发行版 linux 后,它起作用了。