2013-06-20 41 views
12

雖然bundle:install階段deploy:finalize_update後,我得到關於引入nokogiri錯誤。這表明,error關於引入nokogiri而Ubuntu的服務器上部署Capistrano的

** [out :: *******] Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling. 

所以,我想通過自己的server.But安裝引入nokogiri它提供了以下錯誤,

Building native extensions. This could take a while... 
ERROR: Error installing nokogiri: 
    ERROR: Failed to build gem native extension. 

    /home/deployer/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb 
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-linux-gnu/ports/libxml2/2.8.0... OK 
Running 'configure' for libxml2 2.8.0... OK 
Running 'compile' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-linux-gnu/ports/libxml2/2.8.0/compile.log' to see what happened. 
*** 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=. 
    --curdir 
    --ruby=/home/deployer/.rvm/rubies/ruby-2.0.0-p0/bin/ruby 
/home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:235:in `block in execute': Failed to complete compile task (RuntimeError) 
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:227:in `chdir' 
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:227:in `execute' 
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:61:in `compile' 
    from /home/deployer/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems/mini_portile-0.5.0/lib/mini_portile.rb:101:in `cook' 
    from extconf.rb:101:in `block in <main>' 
    from extconf.rb:119:in `call' 
    from extconf.rb:119:in `block in <main>' 
    from extconf.rb:109:in `tap' 
    from extconf.rb:109:in `<main>' 


Gem files will remain installed in /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.6.0 for inspection. 
Results logged to /home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out 

它剛開始today.Also的libxml2已安裝。

有什麼想法?

謝謝。

編輯:我不需要明確nokogiri在我的gemfile中。

+1

我有一個想法:回顧 'TMP/x86_64的-Linux的GNU /端口/ libxml2的/ 2.8.0/compile.log' 看看會發生什麼。 –

+1

:)文件不存在 –

+0

我添加引入nokogiri我的寶石文件及其解決。但給我一個警告。 警告:引入nokogiri始建反對的libxml版本2.9.1,但動態加載2.8.0 –

回答

37

我面臨着引入nokogiri 1.6.0相同的問題。從日誌中可以看到問題,這是由libxml2的編譯失敗引起的,它與libxslt一起被嵌入到gem中,並在安裝時被編譯。

要找出究竟錯在哪裏與編譯,看看建議的文件compile.log,在你的情況,你可以找到:

/home/deployer/.rvm/gems/ruby-2.0.0-p0/gems/nokogiri-1.6.0/ext/nokogiri/tmp/x86_64-linux-gnu/ports/libxml2/2.8.0/compile.log 

作爲一種變通方法(假設你的libxml2-dev的和的libxslt-dev的安裝),你可以這樣做:

NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install 

我希望它能幫助。

+0

謝謝你的解決方法!我認爲它絕對是我的一個自制問題,但沒有時間Google-Fu修復。 – engineerDave

+0

你的解決方法也適用於我。但仍然給我警告。任何關於此問題的公開問題也許我們可以把這個問題附加到它上面。 –

+1

它應該擴大到包含來自@tiago的答案 – nunopolonia

0

基於@zekus答案,我創建了Capistrano的這樣一個新的任務:

task :custom_bundle_install, roles: :app do 
    run "cd /home/#{user}/apps/#{application}/releases/#{release_name} && NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --gemfile /home/#{user}/apps/#{application}/releases/#{release_name}/Gemfile --path /home/#{user}/apps/#{application}/shared/bundle --deployment --quiet --without development test" 
    end 
    before "bundle:install", "deploy:custom_bundle_install" 

這爲我工作得很好。

11

如果您使用Capistrano的3.x中,你可以做你的deploy.rb文件(或環境中的特定文件即deploy/production.rb)以下

set :bundle_env_variables, { 'NOKOGIRI_USE_SYSTEM_LIBRARIES' => 1 } 

這樣你可以避免重寫bundle install任務。這將在運行bundle install時設置給定的env變量。

0

連接到您部署用戶主機,不是試圖自行安裝包:

cd {your last release path} 
bundle config build.nokogiri --with-xml2-include=/usr/include/libxml2/libxml 
bundle install --gemfile Gemfile --path shared/bundle --deployment --quiet --without development test 

比手動運行Capistrano的。

這爲我工作。

相關問題