“捆绑安装”出错

时间:2012-04-11 21:41:58

标签: ruby bundle linecache

运行“bundle install”时出现此错误

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/bin/ruby extconf.rb 
checking for vm_core.h... no

checking for vm_core.h... no

*** 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
    --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=.
    --curdir
    --ruby=/var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/bin/ruby
    --with-ruby-dir
    --without-ruby-dir
    --with-ruby-include
    --without-ruby-include=${ruby-dir}/include
    --with-ruby-lib
    --without-ruby-lib=${ruby-dir}/lib
/var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:243:in `mkdir': Permission denied - /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/include/ruby-1.9.1/ruby-1.9.2-p318 (Errno::EACCES)
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:243:in `fu_mkdir'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:217:in `block (2 levels) in mkdir_p'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:215:in `reverse_each'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:215:in `block in mkdir_p'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:201:in `each'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:201:in `mkdir_p'
    from /var/lib/jenkins/.rvm/gems/ruby-1.9.2-p318/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:59:in `block in create_makefile_with_core'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/tempfile.rb:320:in `open'
    from /var/lib/jenkins/.rvm/gems/ruby-1.9.2-p318/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:51:in `create_makefile_with_core'
    from extconf.rb:19:in `<main>'
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p318.tar.gz
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p318.tar.gz


Gem files will remain installed in /var/lib/jenkins/.bundler/tmp/19915/gems/linecache19-0.5.12 for inspection.
Results logged to /var/lib/jenkins/.bundler/tmp/19915/gems/linecache19-0.5.12/ext/trace_nums/gem_make.out
An error occured while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.

运行gem install linecache19 -v '0.5.12'后,我得到了同样的错误!

我搜索错误但非解决方案有效!

当我运行“chown -R jenkins /var/lib/jenkins/.rvm”时出现此错误:

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/ext'的所有权:不允许操作

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/test_case.rb'的所有权:不允许操作

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/deprecate.rb'的所有权:不允许操作

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/commands/update_command.rb'的所有权:不允许操作

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/commands/outdated_command.rb'的所有权:不允许操作

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/commands/uninstall_command.rb'的所有权:不允许操作

chown:更改`/var/lib/jenkins/.rvm/src/rubygems-1.8.21/lib/rubygems/commands/fetch_command.rb'的所有权:不允许操作
.....

当我用sudo运行命令时没有任何反应!

2 个答案:

答案 0 :(得分:3)

这是缺少头文件的情况。

您需要为您的ruby版本查找或下载ruby源的副本,然后

gem install ruby-debug19 -- --with-ruby-include=path/to/ruby/source/

重新运行bundle install

答案 1 :(得分:0)

重要的是这一行:

/var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/lib/ruby/1.9.1/fileutils.rb:243:in `mkdir': Permission denied - /var/lib/jenkins/.rvm/rubies/ruby-1.9.2-p318/include/ruby-1.9.1/ruby-1.9.2-p318 (Errno::EACCES)

显然,用户无法写入该目录。您应该确保{jenkins用户拥有/var/lib/jenkins/.rvm和所有子对象。假设它是jenkins你可以运行

chown -R jenkins /var/lib/jenkins/.rvm
chmod -R u+rX /var/lib/jenkins/.rvm