Sqlite3: Failed to build gem native extension - ruby-on-rails-3

I'm using Capistrano for the first time and ran into the following problem. My rails app is running on a VPS with CentOS Linux 6.0.
* executing `bundle:install'
* executing "ls -x ~/my_rails_app/releases"
servers: ["example.com"]
[example.com] executing command
command finished in 1225ms
* executing "cd ~/my_rails_app/releases/20120513095446 && bundle install --gemfile ~/my_rails_app/releases/2012051309
5446/Gemfile --path ~/my_rails_app/shared/bundle --deployment --quiet --without development test"
servers: ["example.com"]
[example.com] executing command
** [out :: example.com] /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native
extension. (Gem::Installer::ExtensionBuildError)
** [out :: example.com]
** [out :: example.com] /usr/bin/ruby extconf.rb
** [out :: example.com] checking for sqlite3.h... no
** [out :: example.com] sqlite3.h is missing. Try 'port install sqlite3 +universal'
** [out :: example.com] or 'yum install sqlite-devel' and check your shared library search path (the
** [out :: example.com] location where your sqlite3 shared library is located).
** [out :: example.com] *** extconf.rb failed ***
** [out :: example.com] Could not create Makefile due to some reason, probably lack of
** [out :: example.com] necessary libraries and/or headers. Check the mkmf.log file for more
** [out :: example.com] details. You may need configuration options.
** [out :: example.com]
** [out :: example.com] Provided configuration options:
** [out :: example.com] --with-opt-dir
** [out :: example.com] --without-opt-dir
** [out :: example.com] --with-opt-include
** [out :: example.com] --without-opt-include=${opt-dir}/include
** [out :: example.com] --with-opt-lib
** [out :: example.com] --without-opt-lib=${opt-dir}/lib
** [out :: example.com] --with-make-prog
** [out :: example.com] --without-make-prog
** [out :: example.com] --srcdir=.
** [out :: example.com] --curdir
** [out :: example.com] --ruby=/usr/bin/ruby
** [out :: example.com] --with-sqlite3-dir
** [out :: example.com] --without-sqlite3-dir
** [out :: example.com] --with-sqlite3-include
** [out :: example.com] --without-sqlite3-include=${sqlite3-dir}/include
** [out :: example.com] --with-sqlite3-lib
** [out :: example.com] --without-sqlite3-lib=${sqlite3-dir}/lib
** [out :: example.com] --enable-local
** [out :: example.com] --disable-local
** [out :: example.com]
** [out :: example.com]
** [out :: example.com] Gem files will remain installed in /home/example.com/my_rails_app/shared/bundle/ruby/1.8/gems/sqlite3-1.
3.6 for inspection.
** [out :: example.com] Results logged to /home/example.com/my_rails_app/shared/bundle/ruby/1.8/gems/sqlite3-1.3.6/ext/sqlite3/g
em_make.out
Any ideas?
Thanks in advance!

On Red-hat derivitives, you need to install the development package for sqlite so that the sqlite gem, which uses native extension, builds.
Try:
sudo yum install sqlite-devel
And then do
bundle install

Related

Capistrano deployment can't find certain gems during deployment (Probably RVM related)

I've been trying to deploy to a VPS using Capistrano, and the following command is throwing me a lot of errors:
* executing "cd -- /home/work/for_linode/releases/20130317174830 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile && cp -- /home/work/for_linode/shared/assets/manifest.yml /home/work/for_linode/releases/20130317174830/assets_manifest.yml"
Which results in the following:
servers: ["50.116.11.160"]
[50.116.11.160] executing command
*** [err :: 50.116.11.160] rake aborted!
*** [err :: 50.116.11.160] Could not find activesupport-3.2.11 in any of the sources
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/spec_set.rb:92:in `block in materialize'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/spec_set.rb:85:in `map!'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/spec_set.rb:85:in `materialize'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/definition.rb:114:in `specs'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/definition.rb:159:in `specs_for'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/definition.rb:148:in `requested_specs'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/environment.rb:18:in `requested_specs'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/runtime.rb:13:in `setup'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler.rb:120:in `setup'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/bundler-1.3.4/lib/bundler/setup.rb:17:in `<top (required)>'
*** [err :: 50.116.11.160] /home/work/for_linode/releases/20130317174830/config/boot.rb:6:in `<top (required)>'
*** [err :: 50.116.11.160] /home/work/for_linode/releases/20130317174830/config/application.rb:1:in `<top (required)>'
*** [err :: 50.116.11.160] /home/work/for_linode/releases/20130317174830/Rakefile:5:in `<top (required)>'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
*** [err :: 50.116.11.160] /usr/local/rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'
*** [err :: 50.116.11.160] (See full trace by running task with --trace)
command finished in 1888ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/work/for_linode/releases/20130317174830; true"
servers: ["50.116.11.160"]
[50.116.11.160] executing command
command finished in 1591ms
failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p392' -c 'cd -- /home/work/for_linode/releases/20130317174830 && rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile && cp -- /home/work/for_linode/shared/assets/manifest.yml /home/work/for_linode/releases/20130317174830/assets_manifest.yml'" on 50.116.11.160
I am by no means an expert using capistrano, and the similar questions around here, are related to a problem that's a bit different,
Could you guys please help figure out what's going on?
EDIT:
set :application, "for_linode"
set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
set :bundle_without, [:development]
set :rvm_install_ruby_params, '--1.9.3-p194' # for jruby/rbx default to 1.9 mode
set :rvm_install_pkgs, %w[libyaml openssl] # package list from https://rvm.io/packages
set :rvm_install_ruby_params, '--with-opt-dir=/root/.rvm/usr' # package support
before 'deploy:setup', 'rvm:install_rvm' # install RVM
before 'deploy:setup', 'rvm:install_pkgs' # install RVM packages before Ruby
before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset, or:
before 'deploy:setup', 'rvm:create_gemset' # only create gemset
before 'deploy:setup', 'rvm:import_gemset' # import gemset from file
require "rvm/capistrano"
require "bundler/capistrano"
set :repository, "git://github.com/jlstr/for_linode.git"
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
set :branch, "master"
set :scm, :git
set :user, "root"
set :scm_username, "joe"
set :use_sudo, true
set :deploy_to, '/home/work/for_linode'
#set :rvm_ruby_string, 'ruby-1.9.3-p392'
set :rvm_type, :system
role :web, "50.116.11.160" # Your HTTP server, Apache/etc
role :app, "50.116.11.160" # This may be the same as your `Web` server
#role :db, "", :primary => true # This is where Rails migrations will run
#role :db, "your slave db-server here"
# if you want to clean up old releases on each deploy uncomment this:
# after "deploy:restart", "deploy:cleanup"
# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts
# If you are using Passenger mod_rails uncomment this:
# namespace :deploy do
# task :start do ; end
# task :stop do ; end
# task :restart, :roles => :app, :except => { :no_release => true } do
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# end
# end
require "rvm/capistrano"
load 'deploy/assets'
use this piece of code for assets:
set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
set :bundle_without, [:development]
require "rvm/capistrano"
require "bundler/capistrano"
load 'deploy/assets'
extracted from => https://github.com/mpapis/ad/blob/master/config/deploy.rb

Rails 3 production server complaining that bcrypt-ruby gem is not part of the bundle

As can be seen from the following excerpt of the output of a cap deploy ** [out :: 178.79.170.199] Using bcrypt-ruby (3.0.1) the bcrypt-ruby gem is installed on my server but unicorn is unable to start up properly and is complaining that bcrypt-ruby gem is not part of the bundle.
UPDATE - Exact error message is
/home/myuser/.rvm/gems/ruby-1.9.3-p374#global/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': bcrypt-ruby is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
I have restarted both my nginx server and unicorn.
How can I fix this?
An excerpt of console output from cap deploy
** [out :: 178.79.170.199] Using bcrypt-ruby (3.0.1)
** [out :: 178.79.170.199] Using highline (1.6.15)
** [out :: 178.79.170.199] Using net-ssh (2.6.3)
** [out :: 178.79.170.199] Using net-scp (1.0.4)
** [out :: 178.79.170.199] Using net-sftp (2.0.5)
** [out :: 178.79.170.199] Using net-ssh-gateway (1.1.0)
** [out :: 178.79.170.199] Using capistrano (2.14.1)
** [out :: 178.79.170.199] Using coffee-script-source (1.4.0)
** [out :: 178.79.170.199] Using execjs (1.4.0)
** [out :: 178.79.170.199] Using coffee-script (2.2.0)
** [out :: 178.79.170.199] Using rack-ssl (1.3.3)
** [out :: 178.79.170.199] Using json (1.7.6)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using rdoc (3.12)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using thor (0.17.0)
** [out :: 178.79.170.199] Using railties (3.2.11)
** [out :: 178.79.170.199] Using coffee-rails (3.2.2)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using jquery-rails (2.2.0)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using kgio (2.8.0)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using mysql2 (0.3.11)
** [out :: 178.79.170.199] Using bundler (1.2.3)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using rails (3.2.11)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using raindrops (0.10.0)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using rvm-capistrano (1.2.7)
** [out :: 178.79.170.199]
** [out :: 178.79.170.199] Using sass (3.2.5)
** [out :: 178.79.170.199] Using sass-rails (3.2.6)
** [out :: 178.79.170.199] Using uglifier (1.3.0)
** [out :: 178.79.170.199] Using unicorn (4.5.0)
** [out :: 178.79.170.199] Your bundle is complete! It was installed into /home/myuser/myapp/shared/bundle
I am having no issues with other gems I have installed.
This issue was caused by ensuring that th nginx server was re booted properly. I actually had to re-boot the actual OS for this issue to clear itself up as nginx restarts and unicorn restarts just seemed to have no effect.

Production assets:precompile fails during capistrano deploy

During deploy, I get the following output:
[xx.xxx.xxx.xx] executing command
** [out :: xx.xxx.xxx.xx] ** Invoke assets:precompile (first_time)
** [out :: xx.xxx.xxx.xx] ** Execute assets:precompile
** [out :: xx.xxx.xxx.xx]
** [out :: xx.xxx.xxx.xx] ** Invoke assets:precompile:all (first_time)
** [out :: xx.xxx.xxx.xx] ** Execute assets:precompile:all
** [out :: xx.xxx.xxx.xx] ** Invoke assets:precompile:primary (first_time)
** [out :: xx.xxx.xxx.xx] ** Invoke assets:environment (first_time)
** [out :: xx.xxx.xxx.xx] ** Execute assets:environment
** [out :: xx.xxx.xxx.xx] ** Invoke environment (first_time)
** [out :: xx.xxx.xxx.xx] ** Execute environment
** [out :: xx.xxx.xxx.xx] ** Invoke tmp:cache:clear (first_time)
** [out :: xx.xxx.xxx.xx] ** Execute tmp:cache:clear
** [out :: xx.xxx.xxx.xx] ** Execute assets:precompile:primary
** [out :: xx.xxx.xxx.xx] Killed
bundle -v output is 1.1.5
The solution I've found is to reboot the server and deploy immediately after. Otherwise, I'm unable to deploy to production and I'm not sure how to debug this issue as there is no output other than it dying on deploy.
Edit: server is running Ubuntu 12.04 x64
I have similar issue today, try the solution for this following question
https://stackoverflow.com/a/11893146

Cannot start unicorn.

I'm trying to start my app with unicorn, but cannot start.
I've got an argument error parse_rackup_file: rackup file (config.ru) not readable (ArgumentError)
My environment is rbenv ruby1.9.3 and rails 3.1.3.
What's wrong?
Mac-mini:rails_app Macmini$ cap deploy:start
* executing `deploy:start'
* executing "cd /home/deployer/public_html/rails_app/current/; bundle exec unicorn -c /home/deployer/public_html/rails_app/current/config/unicorn.rb -E production -D"
servers: ["211.125.67.15"]
[211.125.67.15] executing command
*** [err :: 211.125.67.15] /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:610:in `parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:76:in `reload'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:67:in `initialize'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `new'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `initialize'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `new'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
*** [err :: 211.125.67.15] from /home/deployer/public_html/rails_app/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
*** [err :: 211.125.67.15] master failed to start, check stderr log for details
command finished in 1021ms
failed: "env RBENV_ROOT=/usr/local/rbenv PATH=/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH sh -c 'cd /home/deployer/public_html/rails_app/current/; bundle exec unicorn -c /home/deployer/public_html/rails_app/current/config/unicorn.rb -E production -D'" on 211.125.67.15
Mac-mini:rails_app Macmini$
I resolved this issue by adding
working_directory("/path/to/rails_root")
inside config/unicorn.rb
You can refer to the documentation here:
http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-working_directory

Could not find unicorn (>= 0) amongst

I'm currently using capistrano to deploy my project. However I'm having this problem below:
$ cap deploy:start
* executing `deploy:start'
* executing " /usr/local/rvm/gems/ruby-1.9.2-p290/bin/unicorn_rails -c /app/current/config/unicorn.rb -E production -D"
servers: ["x.x.x.x"]
[x.x.x.x] executing command
** [out :: x.x.x.x] /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.**rb:247:in `to_specs': Could not find unicorn (>= 0) amongst [minitest-1.6.0, rake-0.8.7, rdoc-2.5.8]** (
** [out :: x.x.x.x] Gem::LoadError)
** [out :: x.x.x.x] from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
** [out :: x.x.x.x] from /usr/local/rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems.rb:1210:in `gem'
** [out :: x.x.x.x] from /usr/local/rvm/gems/ruby-1.9.2-p290/bin/unicorn_rails:18:in `<main>'
** [out :: x.x.x.x]
command finished in 253ms
failed: "sh -c '/usr/local/rvm/gems/ruby-1.9.2-p290/bin/unicorn_rails -c /app/current/config/unicorn.rb -E production -D'" on x.x.x.x
software version:
rails 3.1
ruby-1.9.2-p290
ubuntu 10.04
Could anyone help? Many thanks!!
Capistrano can't find the right variable of PATH,GEM_PATH and GEM_HOME.You should set them in config/deploy.rb like below:
set :default_environment, {
'PATH' => "/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/ruby-1.9.2-p290#global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:$PATH",
'RUBY_VERSION' => 'ruby 1.9.2p290',
'GEM_HOME' => '/usr/local/rvm/gems/ruby-1.9.2-p290',
'GEM_PATH' => '/usr/local/rvm/gems/ruby-1.9.2-p290:/usr/local/rvm/gems/ruby-1.9.2-p290#global'
}
It seems the Unicorn gem is not installed on the server.
Login into the server and run
which unicorn_rails
If it doesn't return any path, it means it's not available. Login as root, then install it.
$ gem install unicorn