Assets precompile fails on EC2: can't find jQuery - ruby-on-rails

I'm configuring a new production deployment setup with a skeleton rails app, which I just generated using rails new with Rails 3.2.8. I have a production setup on my dev machine with apache2 and Phusion Passenger, which all works fine. When I try to push that configuration to EC2, the assets precompile step fails because it can't find jQuery.
Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'capistrano'
gem 'jquery-rails'
gem 'haml'
group :assets do
gem 'less-rails'
gem 'uglifier', '>= 1.0.3'
gem 'therubyracer'
gem 'execjs'
end
group :deploy do
gem 'passenger'
end
group :production do
gem 'bigdecimal'
end
Relevant bit of deploy.rb
after "deploy:update_code" do
run "cd #{release_path}; rake assets:precompile RAILS_ENV=production "
end
Output
triggering after callbacks for `deploy:update_code'
* executing "cd /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; rake assets:precompile RAILS_ENV=production"
servers: ["bww-test"]
[bww-test] executing command
** [out :: bww-test] /usr/bin/ruby1.9 /usr/local/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
** [out :: bww-test]
** [out :: bww-test] rake aborted!
** [out :: bww-test]
** [out :: bww-test] couldn't find file 'jquery'
** [out :: bww-test] (in /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008/app/assets/javascripts/application.js:13)
** [out :: bww-test]
** [out :: bww-test]
** [out :: bww-test] Tasks: TOP => assets:precompile:primary
** [out :: bww-test]
** [out :: bww-test] (See full trace by running task with --trace)
** [out :: bww-test]
** [out :: bww-test] rake aborted!
** [out :: bww-test] Command failed with status (1): [/usr/bin/ruby1.9 /usr/local/bin/rake asset...]
** [out :: bww-test]
** [out :: bww-test] Tasks: TOP => assets:precompile
** [out :: bww-test] (See full trace by running task with --trace)
command finished in 1819ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; true"
servers: ["bww-test"]
[bww-test] executing command
command finished in 168ms
failed: "sh -c 'cd /home/ec2-user/BWW/pages/bw-widget/releases/20121017095008; rake assets:precompile RAILS_ENV=production'" on bww-test
If I look on the server, the bundle including jQuery has been installed by Capistrano:
[ec2-user#ip-10-226-122-140 bw-widget]$ find . -name jquery\*
./shared/bundle/ruby/1.9.1/specifications/jquery-rails-2.1.3.gemspec
./shared/bundle/ruby/1.9.1/cache/jquery-rails-2.1.3.gem
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/jquery-rails.gemspec
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/generators/jquery
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/jquery
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/lib/jquery-rails.rb
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery_ujs.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery-ui.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery.min.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery.js
./shared/bundle/ruby/1.9.1/gems/jquery-rails-2.1.3/vendor/assets/javascripts/jquery-ui.min.js
./shared/bundle/ruby/1.9.1/gems/rdoc-3.12/lib/rdoc/generator/template/darkfish/js/jquery.js
I'm slightly puzzled that the gems are in ruby/1.9.1 when I'm actually using 1.9.3p0 (the yum install version, not the rvm version), but I don't know if that is significant.
Update
Following a comment from Said, I changed the after update task to:
after "deploy:update_code" do
run "cd #{release_path}; bundle exec rake assets:precompile RAILS_ENV=production "
end
However, none of the documents I've read have suggested that bundle exec should be necessary, so I'm still concerned that while I have a work-around, something still isn't quite configured right.

Related

Error with cap deploy:cold in Digital Ocean for Rails app

I really want to deploy an app and had been following railstutorial by Michael Hartl. Now, I'm about to deploy my first app in Digital Ocean but I keep on running on to a lot of problems. Anyway, most of it was already done except on this big one.
I followed the this blog by Hoang Pham and a tutorial by [Andrew Gertig][3].
Anyways, this is my first entry here. Let me say my thanks in advance.Everytime I do, $ cap deploy:cold, on my local machine I always get this error.
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c
'cd /home/deployer/apps/tiangge/releases/20150123165947 && bundle
install --gemfile
/home/deployer/apps/tiangge/releases/20150123165947/Gemfile --path
/home/deployer/apps/tiangge/shared/bundle --deployment --quiet
--without development test'" on 128.199.74.8
And I also notice this one, that's why I did gem uninstall bundler and gem install bundler again in the VPS
[128.199.74.8] executing command ** [out :: 128.199.74.8] Unfortunately, a fatal error has occurred. Please see the Bundler **
[out :: 128.199.74.8] ** [out :: 128.199.74.8] troubleshooting
complete log:
triggering load callbacks
* 2015-01-23 20:59:18 executing `deploy:cold'
* 2015-01-23 20:59:18 executing `deploy:update'
** transaction: start
* 2015-01-23 20:59:18 executing `deploy:update_code'
triggering before callbacks for `deploy:update_code'
* 2015-01-23 20:59:18 executing `sidekiq:quiet'
* executing "if [ -d /home/deployer/apps/tiangge/current ] && [ -f /home/deployer/apps/tiangge/shared/pids/sidekiq.pid ] && kill -0 `cat /home/deployer/apps/tiangge/shared/pids/sidekiq.pid`> /dev/null 2>&1; then cd /home/deployer/apps/tiangge/current && bundle exec sidekiqctl quiet /home/deployer/apps/tiangge/shared/pids/sidekiq.pid ; else echo 'Sidekiq is not running'; fi"
servers: ["128.199.74.8"]
deployer#128.199.74.8's password:
[128.199.74.8] executing command
** [out :: 128.199.74.8] Sidekiq is not running
** [out :: 128.199.74.8]
command finished in 1328ms
updating the cached checkout on all servers
executing locally: "git ls-remote git#bitbucket.org:bryanbenjamin/tiangge.git master"
command finished in 4069ms
* executing "if [ -d /home/deployer/apps/tiangge/shared/cached-copy ]; then cd /home/deployer/apps/tiangge/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard d87bdfba0860752edddcf6e8c021c1468367aa03 && git clean -q -d -x -f; else git clone -q -b master git#bitbucket.org:bryanbenjamin/tiangge.git /home/deployer/apps/tiangge/shared/cached-copy && cd /home/deployer/apps/tiangge/shared/cached-copy && git checkout -q -b deploy d87bdfba0860752edddcf6e8c021c1468367aa03; fi"
servers: ["128.199.74.8"]
[128.199.74.8] executing command
command finished in 10461ms
copying the cached version to /home/deployer/apps/tiangge/releases/20150123165947
* executing "cp -RPp /home/deployer/apps/tiangge/shared/cached-copy /home/deployer/apps/tiangge/releases/20150123165947 && (echo d87bdfba0860752edddcf6e8c021c1468367aa03 > /home/deployer/apps/tiangge/releases/20150123165947/REVISION)"
servers: ["128.199.74.8"]
[128.199.74.8] executing command
command finished in 1416ms
* 2015-01-23 20:59:49 executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* 2015-01-23 20:59:49 executing `deploy:assets:symlink'
* executing "rm -rf /home/deployer/apps/tiangge/releases/20150123165947/public/assets && mkdir -p /home/deployer/apps/tiangge/releases/20150123165947/public && mkdir -p /home/deployer/apps/tiangge/shared/assets && ln -s /home/deployer/apps/tiangge/shared/assets /home/deployer/apps/tiangge/releases/20150123165947/public/assets"
servers: ["128.199.74.8"]
[128.199.74.8] executing command
command finished in 1290ms
* 2015-01-23 20:59:50 executing `bundle:install'
* executing "cd /home/deployer/apps/tiangge/releases/20150123165947 && bundle install --gemfile /home/deployer/apps/tiangge/releases/20150123165947/Gemfile --path /home/deployer/apps/tiangge/shared/bundle --deployment --quiet --without development test"
servers: ["128.199.74.8"]
[128.199.74.8] executing command
** [out :: 128.199.74.8] Unfortunately, a fatal error has occurred. Please see the Bundler
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:114:in ``'
** [out :: 128.199.74.8] :
** [out :: 128.199.74.8] Cannot allocate memory - git clone 'git://github.com/spree/spree_auth_devise.git' "/home/deployer/apps/tiangge/shared/bundle/ruby/2.1.0/cache/bundler/git/spree_auth_devise-68351354588ecb7fa5d7bc278ebd86436a50d33d" --bare --no-hardlinks --quiet
** [out :: 128.199.74.8] (
** [out :: 128.199.74.8] Errno::ENOMEM
** [out :: 128.199.74.8] )
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:114:in `block in git'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/shared_helpers.rb:62:in `call'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/shared_helpers.rb:62:in `with_clean_git_env'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:114:in `git'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:108:in `block in git_retry'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/retry.rb:38:in `call'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/retry.rb:38:in `run'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/retry.rb:28:in `attempt'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:107:in `git_retry'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git/git_proxy.rb:73:in `checkout'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/source/git.rb:149:in `specs'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/lazy_specification.rb:53:in `__materialize__'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/spec_set.rb:88:in `block in materialize'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/spec_set.rb:85:in `map!'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/spec_set.rb:85:in `materialize'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/definition.rb:132:in `specs'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/definition.rb:121:in `resolve_remotely!'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/installer.rb:79:in `run'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/installer.rb:18:in `install'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/cli/install.rb:79:in `run'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/cli.rb:145:in `install'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor/command.rb:27:in `run'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor/invocation.rb:121:in `invoke_command'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor.rb:363:in `dispatch'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/vendor/thor/base.rb:440:in `start'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/cli.rb:9:in `start'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/bin/bundle:20:in `block in <top (required)>'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/gems/bundler-1.7.12/bin/bundle:18:in `<top (required)>'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/bundle:23:in `load'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/bundle:23:in `<main>'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
** [out :: 128.199.74.8]
** [out :: 128.199.74.8]
** [out :: 128.199.74.8] from /home/deployer/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
** [out :: 128.199.74.8]
command finished in 56236ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deployer/apps/tiangge/releases/20150123165947; true"
servers: ["128.199.74.8"]
[128.199.74.8] executing command
command finished in 1335ms
failed: "rvm_path=$HOME/.rvm $HOME/.rvm/bin/rvm-shell 'default' -c 'cd /home/deployer/apps/tiangge/releases/20150123165947 && bundle install --gemfile /home/deployer/apps/tiangge/releases/20150123165947/Gemfile --path /home/deployer/apps/tiangge/shared/bundle --deployment --quiet --without development test'" on 128.199.74.8
deploy.rb
require "bundler/capistrano"
require "rvm/capistrano"
require 'capistrano/sidekiq'
server "128.199.74.8", :web, :app, :db, primary: true
set :application, "tiangge"
set :user, "deployer"
set :port, 6000
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "git#bitbucket.org:bryanbenjamin/tiangge.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end
task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit #{shared_path}/config/database.yml and add your username and password"
end
after "deploy:setup", "deploy:setup_config"
task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
after "deploy:finalize_update", "deploy:symlink_config"
desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
before "deploy", "deploy:check_revision"
end
Steps that I've done:
-reinstalled bundler and
-tried set :rvm_bin_path, "/usr/share/ruby-rvm/bin" in deploy.rb
and some few things
Gemfile:
source 'https://rubygems.org'
ruby '2.1.3'
gem 'rails', '4.1.8'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'unicorn'
gem 'capistrano'
gem 'rvm-capistrano'
gem 'dotenv-rails'
gem 'capistrano-sidekiq'
gem 'spree', '2.4.2'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-4-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-4-stable'
You've got a Cannot allocate memory error. That means not enough RAM for bundler on your deploying machine.
You can add swap partition to do this, or create a DO droplet with bigger RAM space.
Good tutorial about adding a swap to DO droplet https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-12-04
I had a similar problem trying to deploy Dokku on Digital Ocean / Ubuntu.
Easy fix with 3 lines of code run inside SSH session in the root digital ocean user:
dd if=/dev/zero of=/swapfile bs=1024 count=1024000
mkswap /swapfile
swapon /swapfile
For reference see: http://dev.housetrip.com/2014/07/06/deploy-rails-and-postgresql-app-to-dokku/

deploy capistrano ruby 2.0

what it means, when i deploy my project i have error :
** transaction: commit
* 2014-01-10 15:52:54 executing `deploy:bundle'
* executing "cd /var/www/current; bundle install"
servers: ["10.3.27.72"]
[10.3.27.72] executing command
** [out :: 10.3.27.72] /home/shibanov/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 0 total gem(s) (
** [out :: 10.3.27.72] Gem::LoadError)
** [out :: 10.3.27.72] from /home/shibanov/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin/bundle:22:in `<main>'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin/ruby_executable_hooks:15:in `eval'
** [out :: 10.3.27.72] from /home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin/ruby_executable_hooks:15:in `<main>'
command finished in 41ms
failed: "env PATH=/home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin:/home/shibanov/.rvm/gems/ruby-2.0.0-p195#sprut/bin:/home/shibanov/.rvm/rubies/ruby-2.0.0-p195/bin:/home/shibanov/.rvm/bin:$PATH RUBY_VERSION=ruby-2.0.0-p195 GEM_HOME=/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut GEM_PATH=/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut:/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut BUNDLE_PATH=/home/shibanov/.rvm/gems/uby-2.0.0-p195#sprut sh -c 'cd /var/www/current; bundle install'" on 10.3.27.72
it error happen when i migrate project from ruby 1.9.3 to ruby 2.0
You have to set GEM_HOME accordingly:
$ export GEM_HOME='/home/shibanov/.rvm/gems/ruby-2.0.0-p195'

RAILS_ENV=staging cap deploy fails on rake precompile assets

I set up a t1.micro instance on AWS. I was able to successfully run:
RAILS_ENV=staging rubber:create_staging to create the server, deploy the code, and run the app. I made some changes to the code and want to deploy to my staging server but when I run this command:
RAILS_ENV=staging cap deploy
I get the following error:
* executing "cd -- /mnt/domain-staging/releases/20130321005928 && bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile && cp -- /mnt/domain-staging/shared/assets/manifest.yml /mnt/domain-staging/releases/20130321005928/assets_manifest.yml"
servers: ["staging.domain.com"]
[staging.domain.com] executing command
* [out :: staging.domain.com] /usr/local/rubies/1.9.3-p385/bin/ruby /mnt/domain-staging/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=staging RAILS_GROUPS=assets
* [out :: staging.domain.com]
* [out :: staging.domain.com] rake aborted!
* [out :: staging.domain.com] Command failed with status (): [/usr/local/rubies/1.9.3-p385/bin/ruby /mnt...]
* [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:9:in `ruby_rake_task'
* [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:62:in `block (3 levels) in <top (required)>'
* [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:19:in `invoke_or_reboot_rake_task'
* [out :: staging.domain.com] /mnt/domain-staging/shared/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
* [out :: staging.domain.com] Tasks: TOP => assets:precompile:all
* [out :: staging.domain.com] (See full trace by running task with --trace)
command finished in 223523ms
failed: "/bin/bash -l -c 'cd -- /mnt/domain-staging/releases/20130321005928 && bundle exec rake RAILS_ENV=staging RAILS_GROUPS=assets assets:precompile && cp -- /mnt/domain-staging/shared/assets/manifest.yml /mnt/domain-staging/releases/20130321005928/assets_manifest.yml'" on staging.domain.com
I haven't changed any of the default capistrano recipes and it the code was successfully deployed 1 time. I've been able to run "cap deploy" for my production site but not the staging site. I haven't been able to find anything in the Google group, any help would be appreciated.
You need to adapt your application.rb to include this:
if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test), :profiling => %w[staging development]))
end
This happens due to the high memory consumption while running "assets:precompile". Try to reboot your EC2 instance and run the deploy again, it will probably work. You can also change the instance type in order to enhance the memory of your instance and avoid this kinda issue.

Getting "stack level too deep" error when deploying with Capistrano, Rails 3.1 ruby 1.9.2

Here is the log for the cap deploy script output around where the error occurs. Anny suggestions why this might be happening? Thanks!
[yup.la] executing command
[yup.la] sh -c 'cd /srv/www/portrait/releases/20120406051647 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
** [out :: yup.la] rake aborted!
** [out :: yup.la]
** [out :: yup.la] stack level too deep
** [out :: yup.la] (in /srv/www/portrait/releases/20120406051647/app/assets/stylesheets/mobile.css.scss)
** [out :: yup.la]
** [out :: yup.la] Tasks: TOP => assets:precompile:primary
** [out :: yup.la] (See full trace by running task with --trace)
** [out :: yup.la]
command finished in 30868ms
*** [deploy:update_code] rolling back
* executing "rm -rf /srv/www/portrait/releases/20120406051647; true"
servers: ["yup.la"]
[yup.la] executing command
[yup.la] sh -c 'rm -rf /srv/www/portrait/releases/20120406051647; true'
command finished in 288ms
failed: "sh -c 'cd /srv/www/portrait/releases/20120406051647 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" on yup.la
/Users/victorstan/Sites/portrait ∴
Try to change your sass-rails version from 3.1.5 to 3.1.4 in your Gemfile.

Rakefile not getting deployed with capistrano

I am getting this error when deploying with capistrano:
executing "cd /opt/my_app/dev/releases/20100103021722; rake RAILS_ENV=staging db:migrate"
servers: ["96.30.33.84"]
[96.30.33.84] executing command
** [out :: 96.30.33.84] rake aborted!
** [out :: 96.30.33.84]
** [out :: 96.30.33.84] No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
** [out :: 96.30.33.84]
** [out :: 96.30.33.84] /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2377:in `raw_load_rakefile'
** [out :: 96.30.33.84]
** [out :: 96.30.33.84] (See full trace by running task with --trace)
** [out :: 96.30.33.84]
It randomly just started occurring. I found out the problem was that my new deploys are missing my rake file...however I am deploying from my staging branch and I can confirm that my staging branch has the Rakefile. Somehow it's not getting deployed. Does anyone know how to troubleshoot this?
I assume that you are using some sort of vcs (svn/git/etc.), have the files been ignored by the repo, ie. they aren't getting deployed with the app, thus not showing up on staging?

Resources