Gem :: Installer :: ExtensionBuildError:错误:无法构建gem原生扩展。 Rails Capistrano

时间:2014-08-09 15:08:20

标签: ruby ruby-on-rails-3 capistrano bundler

我有一个运行Ruby ruby​​ 1.9.3p194和Capistrano 2.12.0的Rails 3.2.18应用程序。

我以前能够部署到我们的生产服务器,但我现在正尝试部署到不同的服务器(Ubuntu 12.04 LTS 64bit)进行测试。所以我用所有正确的信息(服务器ip,app name,repo等)改变了我的deploy.rb。

当我进行上限部署时,我得到以下内容:

  * executing `deploy'
  * executing `deploy:update'
 ** transaction: start
  * executing `deploy:update_code'
    executing locally: "git ls-remote git@github.com:app/exigead.git master"
    command finished in 920ms
  * executing "git clone -q git@github.com:app/exigead.git /home/deploy/exigencad/releases/20140809150103 && cd /home/deploy/exigencad/releases/20140809150103 && git checkout -q -b deploy e6efe3c07a4148d840af414ae0fe113adc05a0fa && (echo e6efe3c07a4148d840af414ae0fe113adc05a0fa > /home/deploy/exigencad/releases/20140809150103/REVISION)"
    servers: ["72.14.181.99"]
Password: 
    [72.14.181.99] executing command
 ** [72.14.181.99 :: out] Enter passphrase for key '/home/deploy/.ssh/id_rsa':
Password: 
 ** [72.14.181.99 :: out]
    command finished in 15062ms
  * executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * executing `deploy:assets:symlink'
  * executing "rm -rf /home/deploy/exigencad/releases/20140809150103/public/assets &&\\\n        mkdir -p /home/deploy/exigencad/releases/20140809150103/public &&\\\n        mkdir -p /home/deploy/exigencad/shared/assets &&\\\n        ln -s /home/deploy/exigencad/shared/assets /home/deploy/exigencad/releases/20140809150103/public/assets"
    servers: ["72.14.181.99"]
    [72.14.181.99] executing command
    command finished in 66ms
  * executing `bundle:install'
  * executing "cd /home/deploy/exigencad/releases/20140809150103 && bundle install --gemfile /home/deploy/exigencad/releases/20140809150103/Gemfile --path /home/deploy/exigencad/shared/bundle --deployment --quiet --without development test"
    servers: ["72.14.181.99"]
    [72.14.181.99] executing command
 ** [out :: 72.14.181.99] Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 ** [out :: 72.14.181.99] 
 ** [out :: 72.14.181.99] /usr/bin/ruby1.9.1 extconf.rb
 ** [out :: 72.14.181.99] /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
 ** [out :: 72.14.181.99] from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
 ** [out :: 72.14.181.99] from extconf.rb:36:in `<main>'
 ** [out :: 72.14.181.99] 
 ** [out :: 72.14.181.99] 
 ** [out :: 72.14.181.99] Gem files will remain installed in /home/deploy/exigencad/shared/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1 for inspection.
 ** [out :: 72.14.181.99] Results logged to /home/deploy/exigencad/shared/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
 ** [out :: 72.14.181.99] An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot
 ** [out :: 72.14.181.99] continue.
 ** [out :: 72.14.181.99] Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.
    command finished in 5788ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/deploy/exigencad/releases/20140809150103; true"
    servers: ["72.14.181.99"]
    [72.14.181.99] executing command
    command finished in 76ms
failed: "sh -c 'cd /home/deploy/exigencad/releases/20140809150103 && bundle install --gemfile /home/deploy/exigencad/releases/20140809150103/Gemfile --path /home/deploy/exigencad/shared/bundle --deployment --quiet --without development test'" on 72.14.181.99

看起来bcrypt-ruby无法安装。但是即使捆绑器安装在服务器上也无法运行(必须在部署之前手动完成)

任何人都知道为什么会发生这种情况?

1 个答案:

答案 0 :(得分:1)

我通过执行以下操作解决了这个问题。

安装ruby1.9.1-dev并手动安装bundler gem。

现在所有宝石都在我的服务器上正确构建。