capistrano was working fine, I don't know what I changed, but now I get this:
(cap3, rails4, using capistrano-rvm)
$ cap production deploy --trace
** Invoke production (first_time)
** Execute production
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_rails_env
** Invoke rvm:hook (first_time)
** Execute rvm:hook
** Invoke rvm:check (first_time)
** Execute rvm:check
DEBUG [954551b1] Running ~/.rvm/bin/rvm version as myuser#myip
DEBUG [954551b1] Command: ~/.rvm/bin/rvm version
DEBUG [954551b1] bash: /opt/myuser/.rvm/bin/rvm: No such file or directory
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as myuser#myip: rvm exit status: 127
rvm stdout: Nothing written
rvm stderr: bash: /opt/myuser/.rvm/bin/rvm: No such file or directory
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: rvm exit status: 127
rvm stdout: Nothing written
rvm stderr: bash: /opt/myuser/.rvm/bin/rvm: No such file or directory
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in `exit_status='
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:179:in `block in _execute'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `tap'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `_execute'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:77:in `capture'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/capistrano-rvm-0.1.2/lib/capistrano/tasks/rvm.rake:9:in `block (3 levels) in <top (required)>'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/joelnylund/.rvm/gems/ruby-2.0.0-p353/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => rvm:check
At some point I did install a new ruby, but that seemed to work fine, rvm works fine on the server:
$ which rvm
/usr/local/rvm/bin/rvm
and:
$ rvm list
rvm rubies
=* ruby-2.0.0-p643 [ x86_64 ]
ruby-2.1.2 [ x86_64 ]
I have tried adding to deploy.rb :
set :rvm_type, 'system' set :rvm_bin_path, '/usr/local/rvm/bin/'
Any ideas?
I'm trying to setup Phusion Passenger for Apache on a Ubuntu 12.04 LTS 64-bit server for a Rails 3.2.13 application.
I can run the Rails application perfectly fine using the Webrick server but whenever I run it under Apache I get a 500 Internal Server error and the Apache error log shows the following,
*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /buildout/ruby/ruby-1.9.3-x86_64-linux
# cd /buildout/ruby/ruby-1.9.3-x86_64-linux
*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /buildout/ruby/ruby-1.9.3-x86_64-linux
# cd /buildout/ruby/ruby-1.9.3-x86_64-linux
/var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:67:in `join': can't convert nil into String (TypeError)
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:67:in `extconf_rb'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:178:in `block (2 levels) in compile'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:176:in `chdir'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:176:in `block in compile'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:170:in `each'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:170:in `each_with_index'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:170:in `compile'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:140:in `compile_and_load'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:37:in `start'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:228:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/utils.rb:26:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:102:in `rescue in <main>'
from /usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:30:in `<main>'
*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /buildout/ruby/ruby-1.9.3-x86_64-linux
# cd /buildout/ruby/ruby-1.9.3-x86_64-linux
*** Phusion Passenger: no passenger_native_support.so found for the current Ruby interpreter. Compiling one...
# mkdir -p /buildout/ruby/ruby-1.9.3-x86_64-linux
# cd /buildout/ruby/ruby-1.9.3-x86_64-linux
/var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:67:in `join': can't convert nil into String (TypeError)
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:67:in `extconf_rb'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:178:in `block (2 levels) in compile'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:176:in `chdir'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:176:in `block in compile'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:170:in `each'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:170:in `each_with_index'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:170:in `compile'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:140:in `compile_and_load'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:37:in `start'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/native_support.rb:228:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /var/lib/gems/1.9.1/gems/passenger-4.0.10/lib/phusion_passenger/utils.rb:26:in `<top (required)>'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:102:in `rescue in <main>'
from /usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:30:in `<main>'
[ pid=2036 thr=140218616461056 file=ext/apache2/Hooks.cpp:884 time=2013-08-05 12:42:29.716 ]: Unexpected error in mod_passenger: Cannot spawn application '/home/cms/sandbox': Could not read from the spawn server: Connection reset by peer (104)
Backtrace:
(empty)
I've checked the line in the source code and its referring to a ruby_extension_source_dir. I presume its something wrong with my config somewhere but I've checked the paths for Passenger using the passenger-config tool and they are correct (the relevant Apache config is below),
<IfModule mod_passenger.c>
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.10
PassengerRuby /usr/bin/ruby1.9.1
</IfModule>
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
Recently I upgraded my gems and started adding new stuff to my app like authentication by third party social websites using omniauth gem. On development environment everything is fine and works like a charm.
I am deploying to staging and production servers using capistrano. Basic deployment is fine and working so far, but I have got really strange problems when I want to do migrations when deploying.
I get the following error messages from capistrano:
[my.server.com] executing command
*** [err :: my.server.com] rake aborted!
*** [err :: my.server.com] "\xC5" on US-ASCII
*** [err :: my.server.com]
*** [err :: my.server.com] (See full trace by running task with --trace)
command finished in 2472ms
I was googling all around and couldn't find any relevant solution. I also tried to downgrade rake gem back to 0.8.7 but with no success on the end - the same errors.
After hours of googling and digging in I found the solution that (I hope) may by helpful for someone with a similar or the same problem.
I did bundle exec rake --trace db:migrate on the staging server and got the following error messages:
rake aborted!
"\xC5" on US-ASCII
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `read'
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `<top (required)>'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `require'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `<main>'
So I jumped in to the config/application.rb file to find out what could rise the error. Line 5 of that file loads an external config file:
require 'yaml'
APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
and that external file contains UTF-8 chars, not US-ASCII. So I tried a couple of different solutions to solve that problem.
The only one which worked for me was to add an extra few lines of code on top of config/application.rb file:
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
just to tell rake to load external files using utf-8 encoding. After that change everything went smooth and exactly as expected. Problem solved!
PS.
I really don't know why developers of rake 0.9 have changed previous behavior of rake 0.8 which worked fine for me and probably for you as well for a long time. Maybe you have an idea why? I am very curious.
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