在Ubuntu 10.04中安装RSRuby

时间:2011-05-22 22:28:19

标签: r rubygems install gem ubuntu-10.04

我正在尝试在Ubuntu 10.04上安装RSRuby。我几乎不知道要报告的相关错误消息是什么;我一直在谷歌上搜索几个小时,没有一个命令我尝试解决问题。

以下是一些示例错误消息:

$ sudo gem install rsruby -- --with-R-dir=/usr/lib/R
Building native extensions.  This could take a while...
ERROR:  Error installing rsruby:
    ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb --with-R-dir=/usr/lib/R
checking for main() in -lR... yes
checking for R.h... no

ERROR: Cannot find the R header, aborting.


Gem files will remain installed in /var/lib/gems/1.8/gems/rsruby-0.5.1.1 for inspection.
Results logged to /var/lib/gems/1.8/gems/rsruby-0.5.1.1/ext/gem_make.out

或使用apt-get执行此操作:

$ sudo gem install rsruby --include-dependencies -- --with-R-dir=/usr/lib/R/lib64/R --with-R-lib=/usr/lib/R/lib64/R/bin --with-R-include=/usr/lib/R/lib64/R/include
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Building native extensions.  This could take a while...
ERROR:  Error installing rsruby:
    ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb --with-R-dir=/usr/lib/R/lib64/R --with-R-lib=/usr/lib/R/lib64/R/bin --with-R-include=/usr/lib/R/lib64/R/include
checking for main() in -lR... no

ERROR: Cannot find the R library, aborting.


Gem files will remain installed in /var/lib/gems/1.8/gems/rsruby-0.5.1.1 for inspection.
Results logged to /var/lib/gems/1.8/gems/rsruby-0.5.1.1/ext/gem_make.out

我还从GitHub获得了最新的RSRuby并遵循其2006年PDF手册中的说明:

$ ruby setup.rb config -- --with-R-dir=/usr/lib/R
---> lib
---> lib/rsruby
<--- lib/rsruby
<--- lib
---> ext
/usr/bin/ruby1.8 /home/mars/R/rsruby/ext/extconf.rb --with-R-dir=/usr/lib/R
checking for main() in -lR... yes
checking for R.h... no

ERROR: Cannot find the R header, aborting.
*** /home/mars/R/rsruby/ext/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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=/home/mars/R/rsruby/ext
    --curdir
    --ruby=/usr/bin/ruby1.8
    --with-R-dir
    --with-R-include
    --without-R-include=${R-dir}/include
    --with-R-lib
    --without-R-lib=${R-dir}/lib
    --with-Rlib
    --without-Rlib
setup.rb:655:in `command': system("/usr/bin/ruby1.8" "/home/mars/R/rsruby/ext/extconf.rb" "--with-R-dir=/usr/lib/R") failed (RuntimeError)
    from setup.rb:660:in `ruby'
    from setup.rb:1238:in `extconf'
    from setup.rb:1230:in `config_dir_ext'
    from setup.rb:1532:in `__send__'
    from setup.rb:1532:in `traverse'
    from setup.rb:1549:in `dive_into'
    from setup.rb:1530:in `traverse'
    from setup.rb:1524:in `exec_task_traverse'
    from setup.rb:1519:in `each'
    from setup.rb:1519:in `exec_task_traverse'
    from setup.rb:1223:in `exec_config'
    from setup.rb:991:in `exec_config'
    from setup.rb:826:in `__send__'
    from setup.rb:826:in `invoke'
    from setup.rb:773:in `invoke'
    from setup.rb:1578

irb

irb(main):002:0> require 'RSRuby'
LoadError: no such file to load -- RSRuby
    from (irb):2:in `require'
    from (irb):2
    from :0
irb(main):003:0> rsruby
NameError: undefined local variable or method `rsruby' for main:Object
    from (irb):3
    from :0

有时我似乎能够获得看起来有效的内容,但仍然无法从rsruby命令行加载irb

$ sudo gem install rsruby --include-dependencies -- --with-R-dir=/usr/lib/R --with-R-lib=/usr/lib/R --with-R-include=/usr/share/R/include/
INFO:  `gem install -y` is now default and will be removed
INFO:  use --ignore-dependencies to install only the gems you list
Building native extensions.  This could take a while...
Successfully installed rsruby-0.5.1.1
1 gem installed
Installing ri documentation for rsruby-0.5.1.1...
Installing RDoc documentation for rsruby-0.5.1.1...

然后

$ irb
irb(main):001:0> require 'rsruby'
LoadError: no such file to load -- rsruby
    from (irb):1:in `require'
    from (irb):1
    from :0

Ruby是版本1.8.7,我今天做sudo apt-get install ruby1.8-dev但是我不确定这是否会使事情变得更糟,更好或不变。或者如果在ruby1.9中更容易。

R正在发挥作用。

4 个答案:

答案 0 :(得分:6)

我不读日语,但这对我有用,在Ubuntu 10.10,ruby 1.9:http://d.hatena.ne.jp/cuspos/20090520/1242825057

# gem install rsruby-0.5.1.1.gem -- --with-R-dir=/usr/lib/R --with-R-include=/usr/share/R/include 
Building native extensions.  This could take a while...
Successfully installed rsruby-0.5.1.1
1 gem installed
# export R_HOME=/usr/lib/R
# irb 
irb(main):001:0> require 'rsruby'
=> true
irb(main):002:0>

答案 1 :(得分:3)

您可能想要检查您的PATH变量或动态链接是否已设置,以便Ruby和朋友在正确的位置“查找”。 Ruby似乎期望RSruby位于/var/lib/gems/1.8/gems/rsruby-0.5.1.1//usr/lib/ruby/1.8/rubygems//var/lib/gems/1.8/gems/rsruby-0.5.1.1/lib/,....而您的配置报告称它已安装在/usr/bin/ruby1.8 /home/chris/R/中。我没有大量的Linux经验,但我所做的已经告诉我,每个发行版在预期找到已安装的可执行文件的位置方面都有所不同。

答案 2 :(得分:0)

您对apt-getgem install的尝试表明安装程序无法找到R头文件。我将首先解决此问题,而不是尝试其他方式安装RSruby。接下来的问题是为什么它找不到R头,有两种选择:

  • 已安装标头,但找不到它们。使用locate R.h查找R头文件所在的位置,并确保它位于$PATH
  • 标题安装(我怀疑是这种情况)。通常安装头文件需要安装开发包。尝试查看是否有一个R-dev包或类似的名称,其中包含R头文件。可以使用R-dev安装此apt-get。我认为ubuntu 10.04中R的标准版本并不是最新的。 CRAN有ubuntu repositories,其中dev包称为r-base-dev。将此回购添加到sources.list,可以通过apt-get从CRAN获取最新版本的R。

答案 3 :(得分:-1)

您已成功安装了rsruby,如第5个示例的输出所示:

Successfully installed rsruby-0.5.1.1
1 gem installed

库没有加载irb,因为使用Ruby 1.8.7,你需要先“需要rubygems”。在irb中试试这个:

require 'rubygems'
require 'rsruby'