我有ruby2.2,ubuntu 14.04.4 LTS,我想安装rsruby gem。一切都已设置好,所有其他宝石都已设置完成,并附带“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
所以,我的问题是,我该如何调试呢?如何使用捆绑安装?谢谢!
UPDATE,正如matt在评论中指出的那样,两个命令安装的rsruby gem的版本是不同的。如果我更改我的Gemfile以指定bundle来安装版本“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 */
答案 0 :(得分:0)
好的,所以这里发生了一些不同的事情。我将在这里记录所有内容以防其他需要使用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来获得更新版本的ruby。在任何情况下,在更新到当前版本的ruby的当前版本的linux后,它都有效。