安装在Ubuntu上使用本机扩展的Gem时出错,Ruby 1.9.2通过RVM [英] Error installing gems that use native extensions on Ubuntu, Ruby 1.9.2 via RVM

查看:113
本文介绍了安装在Ubuntu上使用本机扩展的Gem时出错,Ruby 1.9.2通过RVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 〜 -  16:54> gem i ffi $ b在安装ffi gem时出现错误:

$ b构建本地扩展。这可能需要一段时间...
错误:安装ffi时出错:
错误:无法构建gem本机扩展。

rake RUBYARCHDIR = / home / mdemare / .rvm / gems / ruby​​-1.9.2-p136 / gems / ffi-1.0.6 / lib RUBYLIBDIR = / home / mdemare / .rvm / gems / ruby-1.9.2-p136 / gems / ffi-1.0.6 / lib
/home/mdemare/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems .rb:370:在`bin_path'中:使用可执行rake(Gem :: GemNotFoundException)无法找到gem rake([> = 0])$ / b / b / from /home/mdemare/.rvm/gems/ ruby-1.9.2-p136 / bin / rake:19:在< main>'

Gem文件将保留安装在/home/mdemare/.rvm/gems/ruby-1.9.2 -p136 / gems / ffi-1.0.6进行检查。
结果记录到/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/gen/gem_make.out

我在使用本机扩展安装gem时遇到各种各样的错误,所以我认为我的Ubuntu安装有些问题,但我没有想法是什么。我会发布你需要的任何信息来诊断问题。编辑:当我cd到ffi宝石(在第二行中提到但最后一行),并运行我得到找不到RubyGem rake-compiler。



在我编译了rake编译器之后,再次运行rake,我得到了这个结果:

  configure:error:源目录已配置;首先运行make distclean
make:*** [/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/build/x86_64-linux/ffi_c /1.9.2/libffi/.libs/libffi_convenience.a]错误1
rake中止!
命令失败,状态为(2):[make ...]

更新:



以下是我的rake gemspecs:

 〜 -  10:59>找到〜/ .rvm / -name'rake-0.8.7.gemspec'
〜/ .rvm / gems / ruby​​-1.9.2-p136 / specifications / rake-0.8.7.gemspec
〜 /.rvm/gems/ruby-1.9.2-p136@global/specifications/rake-0.8.7.gemspec
〜/ .rvm / rubies / ruby​​-1.9.2-p136 / lib / ruby​​ / gems / 1.9.1 / specifications / rake-0.8.7.gemspec

最后一个是gem的外观,但是gemspec与第一个不同,并且不包含可执行文件。虽然复制长文件并不能解决问题,但我得到的文件未找到rake可执行文件。

在试图安装Vagrant(FFI是依赖项)时,波士顿黑客日给我造成了很大的影响。我最终浪费了很多时间,因此我换了一台机器来解决这个问题。



事实之后,我发现了一个可行的破解(尽管我确信有一个更好的解决方案)错误消息正在抱怨的文件

 〜/ .rvm / gems / ruby​​-1.9.2-p180 / bin / rake 

不同于其他类似的副本,因为它缺少头部路径设置的东西,所以我复制了这些来自其中一个文件的行:

[通过下面的@ danv的答案进行通用化。感谢您的改进!]

  ENV ['GEM_HOME'] = ENV ['GEM_HOME'] || '〜/ .rvm / gems / ruby​​-1.9.2-p180'
ENV ['GEM_PATH'] = ENV ['GEM_PATH'] || '〜/ .rvm / gems / ruby​​-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180@global'
ENV ['PATH'] ='〜/ .rvm / gems / ruby​​-1.9.2-p180 / bin:~/.rvm/gems/ruby-1.9.2-p180@global/bin:〜/ .rvm / rubies / ruby​​-1.9.2-p180 / bin:'+ ENV ['PATH']

为我解决了这个问题。这是一个新的Ubuntu 10.10安装,没有默认的Ruby安装(这可能是问题的一部分),使用RVM安装Ruby 1.9.2。许多其他宝石安装正常,包括需要本地编译的宝石,所以问题是FFI特有的。


I get an error while trying to install the ffi gem:

~ - 16:54>gem i ffi
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
        ERROR: Failed to build gem native extension.

        rake RUBYARCHDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib RUBYLIBDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib
/home/mdemare/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:370:in `bin_path': can't find gem rake ([">= 0"]) with executable rake (Gem::GemNotFoundException)
        from /home/mdemare/.rvm/gems/ruby-1.9.2-p136/bin/rake:19:in `<main>'

Gem files will remain installed in /home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6 for inspection.
Results logged to /home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/gen/gem_make.out

I'm getting frequent errors of all kinds while installing gems with native extensions, so I assume that there's something broken with my Ubuntu installation, but I've no idea what. I'll post any information you need to diagnose the problem.

EDIT: When I cd to the ffi gem (mentioned in the second but last line), and run the rake line in line 6, I get "Could not find RubyGem rake-compiler".

After gem i rake-compiler, and run rake again, I get this:

configure: error: source directory already configured; run "make distclean" there first
make: *** [/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/build/x86_64-linux/ffi_c/1.9.2/libffi/.libs/libffi_convenience.a] Error 1
rake aborted!
Command failed with status (2): [make...]

Update:

These are my rake gemspecs:

~ - 10:59>find ~/.rvm/ -name 'rake-0.8.7.gemspec'
~/.rvm/gems/ruby-1.9.2-p136/specifications/rake-0.8.7.gemspec
~/.rvm/gems/ruby-1.9.2-p136@global/specifications/rake-0.8.7.gemspec
~/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/specifications/rake-0.8.7.gemspec

The last one is where gem looks, but that gemspec is different from the first one, and doesn't include the executable. Copying the long one doesn't quite solve the problem though - I get a file not found for the rake executable.

解决方案

This caused me a ton of aggravation at the Boston Hack Day when trying to install Vagrant (for which FFI is a dependency). I ended up wasting so much time that I switched machines to work around the problem.

After the fact, I found a hack that works (although I'm sure there's a better solution). The file that the error message is complaining about

~/.rvm/gems/ruby-1.9.2-p180/bin/rake

differs from other similar copies in that it's missing path setup stuff at the head, so I copied these lines from one of the files that had them:

[genericized per @danv's answer below. Thanks for the improvement!]

ENV['GEM_HOME']=ENV['GEM_HOME'] || '~/.rvm/gems/ruby-1.9.2-p180'
ENV['GEM_PATH']=ENV['GEM_PATH'] || '~/.rvm/gems/ruby-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180@global'
ENV['PATH']='~/.rvm/gems/ruby-1.9.2-p180/bin:~/.rvm/gems/ruby-1.9.2-p180@global/bin:~/.rvm/rubies/ruby-1.9.2-p180/bin:' + ENV['PATH']

That fixed it for me. This was a new Ubuntu 10.10 install with no default Ruby installation (which could be part of the problem) and Ruby 1.9.2 installed using RVM. Lots of other gems installed fine, including those requiring native compilation, so the problem is something specific to FFI.

这篇关于安装在Ubuntu上使用本机扩展的Gem时出错,Ruby 1.9.2通过RVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆