Assets Precompile not finding gems - ruby-on-rails

I'm trying to use capistrano 3.0 to fully manage my deploy, from bundle install to precompile. However, I keep running into a problem where "RAILS_ENV=production rake assets:precompile" can't seem to find the gems that bundler installed. Here's the output from capistrano:
DEBUG [8d404b6a] Finished in 1.289 seconds with exit status 0 (successful).
INFO [9eb1acdc] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/FingertipRails/releases/20131127152604/Gemfile --path /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global --deployment --binstubs /var/www/html/FingertipRails/shared/bin --without development test on 50.112.106.148
DEBUG [9eb1acdc] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/FingertipRails/releases/20131127152604/Gemfile --path /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global --deployment --binstubs /var/www/html/FingertipRails/shared/bin --without development test
DEBUG [9eb1acdc] Your bundle is complete!
DEBUG [9eb1acdc] Gems in the groups development and test were not installed.
DEBUG [9eb1acdc] It was installed into /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global
INFO [9eb1acdc] Finished in 2.892 seconds with exit status 0 (successful).
DEBUG [0de28eb8] Running if test ! -d /var/www/html/FingertipRails/releases/20131127152604; then echo "Directory does not exist '/var/www/html/FingertipRails/releases/20131127152604'" 1>&2; false; fi on 50.112.106.148
DEBUG [0de28eb8] Command: if test ! -d /var/www/html/FingertipRails/releases/20131127152604; then echo "Directory does not exist '/var/www/html/FingertipRails/releases/20131127152604'" 1>&2; false; fi
DEBUG [0de28eb8] Finished in 1.506 seconds with exit status 0 (successful).
INFO [cb071501] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile on 50.112.106.148
DEBUG [cb071501] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
DEBUG [cb071501] /home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [cb071501] :
DEBUG [cb071501] Could not find hashr-0.0.22 in any of the sources
DEBUG [cb071501] (
Here is my staging.rb (I'm using "cap staging deploy"):
set :stage, :staging
set :rails_env, "production"
set :user, "ec2-user"
role :app, %w{50.112.106.148}
role :web, %w{50.112.106.148}
role :db, %w{50.112.106.148}
server '50.112.106.148', user: 'ec2-user', roles: %w{web app}
And here is my deploy.rb:
set :application, 'FingertipRails'
set :repo_url, 'git#github.com:dresources/FingertipRails.git'
set :branch, "master"
set :rvm_type, :user
set :bundle_cmd, "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/bin/bundle"
set :bundle_dir, "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global"
set :bundle_flags, '--deployment'
Any ideas?
Thank you
EDIT
Here is the output of rvm info on the server:
ruby-2.0.0-p247:
system:
uname: "Linux ip-10-226-137-104 3.4.62-53.42.amzn1.x86_64 #1 SMP Fri Sep 20 07:23:24 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux"
system: "amazon/2013.09/x86_64"
bash: "/bin/bash => GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.23.8 (master) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "1 month 10 days 44 minutes 13 seconds ago"
path: "/home/ec2-user/.rvm"
ruby:
interpreter: "ruby"
version: "2.0.0p247"
date: "2013-06-27"
platform: "x86_64-linux"
patchlevel: "2013-06-27 revision 41674"
full_version: "ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]"
homes:
gem: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247"
ruby: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247"
binaries:
ruby: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/ruby"
irb: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/irb"
gem: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin/gem"
rake: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin/rake"
environment:
PATH: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global/bin:/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/bin:/home/ec2-user/.rvm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/bin"
GEM_HOME: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247"
GEM_PATH: "/home/ec2-user/.rvm/gems/ruby-2.0.0-p247:/home/ec2-user/.rvm/gems/ruby-2.0.0-p247#global"
MY_RUBY_HOME: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247"
IRBRC: "/home/ec2-user/.rvm/rubies/ruby-2.0.0-p247/.irbrc"
RUBYOPT: ""
gemset: ""

In your Capistrano task, try adding the bundle_cmd variable you've set in your config so that rake assets:precompile runs with bundle exec. Without seeing what other variables you have in your deploy.rb, you'll want to get this line:
DEBUG [cb071501] Command: cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
... to look more like this:
cd /var/www/html/FingertipRails/releases/20131127152604 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 bundle exec rake assets:precompile )

Related

Can't deploy to my EC2 instance with capistrano 3 anymore

When I try to deploy my application with capistrano it stucks after the command:
~/.rvm/bin/rvm default do ruby --version
This is how the console print looks like:
root#srv:/var/www/project# cap staging deploy
(in /var/www/project)
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
system
Nothing happens after this. It worked fine for a long time but since I've started bundle install (or maybe someone else changed anyhting) the deployment doesn't work anymore. Here's an excerpt of the log file:
INFO ---------------------------------------------------------------------------
INFO START 2021-02-11 13:39:04 +0100 cap staging deploy
INFO ---------------------------------------------------------------------------
DEBUG [08de3cd7] Running ~/.rvm/bin/rvm version as deploy#x.xxx.xx.xx
DEBUG [08de3cd7] Command: ~/.rvm/bin/rvm version
DEBUG [08de3cd7] rvm 1.29.12-next (master) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
DEBUG [08de3cd7]
DEBUG [08de3cd7] Finished in 0.773 seconds with exit status 0 (successful).
DEBUG [17018c10] Running ~/.rvm/bin/rvm current as deploy#x.xxx.xx.xx
DEBUG [17018c10] Command: ~/.rvm/bin/rvm current
DEBUG [17018c10] system
DEBUG [17018c10]
DEBUG [17018c10] Finished in 0.303 seconds with exit status 0 (successful).
DEBUG [41115234] Running ~/.rvm/bin/rvm default do ruby --version as deploy#x.xxx.xx.xx
DEBUG [41115234] Command: ~/.rvm/bin/rvm default do ruby --version
As you can see I am using rvm 1.29.12 with ruby 2.5.1p5. Maybe someone had the same problem or can give me a hint what to do. I have been searching for a solution since hours...
Please try to check your setup first using the below command and check what the error is
cap staging deploy:check

capistrano is pulling the wrong ruby version from rvm

I have a rails 5 app. I was trying to hunt down a memory leak and it opened up a can of worms. One of the worms is rvm and deploy. I do not have
rvm_ruby_string
set anywhere in the project. If I go to the directory of the project, and do either
bundle exec ruby --version
or
ruby --version
both result in
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin14]
However, if I do
cap staging deploy
you can see it somehow picks up the wrong version:
DEBUG [778e15cb] Running /usr/bin/env which passenger as deploy#xxxx
DEBUG [778e15cb] Command: /usr/bin/env which passenger
DEBUG [778e15cb] /usr/bin/passenger
DEBUG [778e15cb] Finished in 0.710 seconds with exit status 0 (successful).
DEBUG [0da5c891] Running [ -d ~/.rvm ] as xxx
DEBUG [0da5c891] Command: [ -d ~/.rvm ]
DEBUG [0da5c891] Finished in 0.101 seconds with exit status 0 (successful).
DEBUG [f2734c3e] Running ~/.rvm/bin/rvm version as
xxx
DEBUG [f2734c3e] Command: ~/.rvm/bin/rvm version
DEBUG [f2734c3e] rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski,
Wayne E.
Seguin [https://rvm.io/]
DEBUG [f2734c3e] Finished in 0.268 seconds with exit status 0 (successful).
rvm 1.29.1 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin
[https://rvm.io/]
DEBUG [a2e3d82a] Running ~/.rvm/bin/rvm current as xx
DEBUG [a2e3d82a] Command: ~/.rvm/bin/rvm current
DEBUG [a2e3d82a] ruby-2.5.0
Now if I simply try to mimic what capistrano says it's doing, by copying and pasting the following to the command line:
~/.rvm/bin/rvm current
I get
ruby-2.3.1
So, I'm stumped. Where is Capistrano pulling the rvm var from?
You are probably running cap staging deploy as a different user then when you ran ruby --version.
Based on the capistrano output, you are using deploy user to deploy. If this is the case, you need to install ruby 2.3.1 as deploy user, and set 2.3.1 to "default and current".
You can test this by running ruby --version as both deploy user and the other user you used to run it the first time.

Deploy Rails 5.1 / Webpacker app with Capistrano

I have an Ubuntu server to deploy my Rails projects. In my Ubuntu server I had RVM.
Now I want to deploy new projects with Rails 5.1 and webpacker. To deploy this projects, I've installed NVM, npm and yarn in my Ubuntu server.
In my Rails 5.1 / Webpacker project I have following gems for capistrano deployment:
Gemfile
group :development do
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano-passenger'
gem 'capistrano-nvm', require: false
gem 'capistrano-yarn'
end
In deploy.rb I've added some configurations for capistrano nvm and capistrano yarn.
deploy.rb
set :nvm_type, :user # or :system, depends on your nvm setup
set :nvm_node, 'v7.10.0'
set :nvm_map_bins, %w{node npm yarn}
set :yarn_target_path, -> { release_path.join('client') } #
set :yarn_flags, '--production --silent --no-progress' # default
set :yarn_roles, :all # default
set :yarn_env_variables, {}
Also I've added node_modules in linked_dirs.
deploy.rb
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system node_modules client/node_modules}
The problem comes when I execute cap deploy in assets:precompile step. Next you have the error log.
terminal log
00:10 deploy:assets:precompile
01 /usr/local/rvm/bin/rvm 2.4.1#project do bundle exec rake assets:precompile
01 Yarn executable was not detected in the system.
01 Download Yarn at https://yarnpkg.com/en/docs/install
01 /home/deploy/rails/241/project/shared/bundle/ruby/2.4.0/bin/rake: No such file or directory - node
01 Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host xxx.xxx.xxx.xxx: rake exit status: 1
rake stdout: Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
/home/deploy/rails/241/project/shared/bundle/ruby/2.4.0/bin/rake: No such file or directory - node
Node.js not installed. Please download and install Node.js
https://nodejs.org/en/download/
rake stderr: Nothing written
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
/home/deploy/rails/241/project/shared/bundle/ruby/2.4.0/bin/rake: No such file or directory - node
Node.js not installed. Please download and install Node.js
https://nodejs.org/en/download/
rake stderr: Nothing written
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing on host xxx.xxx.xxx.xxx: rake exit status: 1
rake stdout: Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
/home/deploy/rails/241/project/shared/bundle/ruby/2.4.0/bin/rake: No such file or directory - node
Node.js not installed. Please download and install Node.js
https://nodejs.org/en/download/
rake stderr: Nothing written
** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:
DEBUG [016276ab] * spring (2.0.1)
DEBUG [016276ab] * spring-watcher-listen (2.0.1)
DEBUG [016276ab] * web-console (3.5.0)
DEBUG [016276ab] Install missing gems with `bundle install`
DEBUG [016276ab] Finished in 0.677 seconds with exit status 1 (failed).
INFO [86e74b01] Running /usr/local/rvm/bin/rvm 2.4.1#project do bundle install --path /home/deploy/rails/241/project/shared/bundle --without development test --deployment --quiet on xxx.xxx.xxx.xxx
DEBUG [86e74b01] Command: cd /home/deploy/rails/241/project/releases/20170511083021 && ( export NODE_VERSION="v7.10.0" ; /usr/local/rvm/bin/rvm 2.4.1#project do bundle install --path /home/deploy/rails/241/project/shared/bundle --without development test --deployment --quiet )
DEBUG [86e74b01] Warning, new version of rvm available '1.29.1', you are using older version '1.26.11'.
You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc
INFO [86e74b01] Finished in 3.209 seconds with exit status 0 (successful).
DEBUG [4a428031] Running if test ! -d /home/deploy/rails/241/project/releases/20170511083021; then echo "Directory does not exist '/home/deploy/rails/241/project/releases/20170511083021'" 1>&2; false; fi on xxx.xxx.xxx.xxx
DEBUG [4a428031] Command: if test ! -d /home/deploy/rails/241/project/releases/20170511083021; then echo "Directory does not exist '/home/deploy/rails/241/project/releases/20170511083021'" 1>&2; false; fi
DEBUG [4a428031] Finished in 0.066 seconds with exit status 0 (successful).
INFO [d225a8b5] Running /usr/local/rvm/bin/rvm 2.4.1#project do bundle exec rake assets:precompile on xxx.xxx.xxx.xxx
DEBUG [d225a8b5] Command: cd /home/deploy/rails/241/project/releases/20170511083021 && ( export NODE_VERSION="v7.10.0" RAILS_ENV="production" ; /usr/local/rvm/bin/rvm 2.4.1#project do bundle exec rake assets:precompile )
DEBUG [d225a8b5] Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
DEBUG [d225a8b5] /home/deploy/rails/241/project/shared/bundle/ruby/2.4.0/bin/rake: No such file or directory - node
DEBUG [d225a8b5] Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/
Thanks in advance!
I prefer to compile assets locally and then copy to the production servers with rsync:
# lib/capistrano/tasks/precompile.rake
namespace :assets do
desc 'Precompile assets locally and then rsync to web servers'
task :precompile do
run_locally do
with rails_env: stage_of_env do
execute :bundle, 'exec rake assets:precompile'
end
end
on roles(:web), in: :parallel do |server|
run_locally do
execute :rsync,
"-a --delete ./public/packs/ #{fetch(:user)}##{server.hostname}:#{shared_path}/public/packs/"
execute :rsync,
"-a --delete ./public/assets/ #{fetch(:user)}##{server.hostname}:#{shared_path}/public/assets/"
end
end
run_locally do
execute :rm, '-rf public/assets'
execute :rm, '-rf public/packs'
end
end
end
# config/deploy.rb
after 'deploy:updated', 'assets:precompile'
In your Capfile you need to include all the capistrano tasks:
# Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/**/*.rake').each { |r| import r }
This eliminates the need to install node and yarn on the production servers.
Of course you need node and yarn installed locally
What worked for me was making sure NVM was included in the PATH. By default, in a bash terminal, NVM adds its environment variables to the end of ~/.bashrc, but much of that file is not usually executed in a non-interactive terminal (which Capistrano runs in). I found this comment helpful:
Put your NVM source script in your .bashrc which is still evaluated even during an non-interactive SSH session. Just make sure you place the declarations at the top, before the case statement:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
The error tells you pretty much what's wrong. Neither Yarn or Node can be found on the server. Your installation might be incorrect.
Follow instructions to install both here:
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
and here:
https://yarnpkg.com/lang/en/docs/install/#linux-tab
Then make sure you can call:
yarn
node
On the server. If not, you might need to add paths to executables into your PATH variable
First - Install Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
Second - Install NodeJS(now 14 is newest):
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

rails capistano mac os deploy error

When I used linux everything deploy work, but when I deploy from mac os, I have:
> cap production deploy
DEBUG [1330f96c] Running /usr/bin/env [ -d ~/.rvm ] on IP Adress
DEBUG [1330f96c] Command: [ -d ~/.rvm ]
Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text.
user_name#ip_adress's password:
When I wrote password, I get
> DEBUG [de2b7c18] Finished in 4.376 seconds with exit status 0 (successful).
DEBUG [1ca89b99] Running ~/.rvm/bin/rvm version on ip address
DEBUG [1ca89b99] Command: ~/.rvm/bin/rvm version
DEBUG [1ca89b99] rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
DEBUG [1ca89b99]
DEBUG [1ca89b99] Finished in 1.130 seconds with exit status 0 (successful).
rvm 1.26.10 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]
DEBUG [1c973067] Running ~/.rvm/bin/rvm current on ip address
DEBUG [1c973067] Command: ~/.rvm/bin/rvm current
DEBUG [1c973067] ruby-2.2.0
DEBUG [1c973067]
DEBUG [1c973067] Finished in 2.110 seconds with exit status 0 (successful).
ruby-2.2.0
DEBUG [848d3c3e] Running ~/.rvm/bin/rvm default do ruby --version on ip address
DEBUG [848d3c3e] Command: ~/.rvm/bin/rvm default do ruby --version
DEBUG [848d3c3e] ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
DEBUG [848d3c3e]
DEBUG [848d3c3e] Finished in 1.050 seconds with exit status 0 (successful).
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
INFO [8dbfa807] Running /usr/bin/env mkdir -p /tmp/project/ on ip address
DEBUG [8dbfa807] Command: /usr/bin/env mkdir -p /tmp/project/
INFO [8dbfa807] Finished in 0.381 seconds with exit status 0 (successful).
DEBUG Uploading /tmp/project/git-ssh.sh 0.0%
INFO Uploading /tmp/project/git-ssh.sh 100.0%
INFO [0f9c9d2a] Running /usr/bin/env chmod +x /tmp/project/git-ssh.sh on ip address
DEBUG [0f9c9d2a] Command: /usr/bin/env chmod +x /tmp/project/git-ssh.sh
INFO [0f9c9d2a] Finished in 1.417 seconds with exit status 0 (successful).
INFO [5dfc2373] Running /usr/bin/env git ls-remote --heads git#bitbucket.org:nick_name/project.git on ip address
DEBUG [5dfc2373] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/project/git-ssh.sh /usr/bin/env git ls-remote --heads git#bitbucket.org:nick_name/project.git )
DEBUG [5dfc2373] Enter passphrase for key '/home/nick_name/.ssh/id_rsa':
I install gem HighLine.
Please help me with this problem?
You could try using a key with no password, or make sure that if your user password and the key's passphrase are different that you are using the correct one. The first prompt is for your user account, user_name#ip_adress, and the second is for the passphrase assigned to /home/nick_name/.ssh/id_rsa.

Still getting gem not found with capistrano

I've been trying to configure my deployment with capistrano for a few weeks now, and it still is not working properly. Every time I deploy to my server I get an error saying a gem is missing, like:
DEBUG [a0e618f0] /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [a0e618f0] :
DEBUG [a0e618f0] Could not find ansi-1.4.3 in any of the sources
DEBUG [a0e618f0] (
DEBUG [a0e618f0] Bundler::GemNotFound
DEBUG [a0e618f0] )
I know how to fix this, simply install the "ansi" gem, but there is a much bigger problem here: why didn't bundler work properly with capistrano??
When I look higher in the output I see:
INFO [1ee9a88e] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/SparkMyInterest/releases/20131122204608/Gemfile --path /var/www/html/SparkMyInterest/shared/bundle --deployment --quiet --binstubs /var/www/html/SparkMyInterest/shared/bin --without development test on 54.200.196.1
DEBUG [1ee9a88e] Command: cd /var/www/html/SparkMyInterest/releases/20131122204608 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do bundle --gemfile /var/www/html/SparkMyInterest/releases/20131122204608/Gemfile --path /var/www/html/SparkMyInterest/shared/bundle --deployment --quiet --binstubs /var/www/html/SparkMyInterest/shared/bin --without development test )
INFO [1ee9a88e] Finished in 20.132 seconds with exit status 0 (successful).
DEBUG [7d1a9e40] Running if test ! -d /var/www/html/SparkMyInterest/releases/20131122204608; then echo "Directory does not exist '/var/www/html/SparkMyInterest/releases/20131122204608'" 1>&2; false; fi on 54.200.196.1
DEBUG [7d1a9e40] Command: if test ! -d /var/www/html/SparkMyInterest/releases/20131122204608; then echo "Directory does not exist '/var/www/html/SparkMyInterest/releases/20131122204608'" 1>&2; false; fi
DEBUG [7d1a9e40] Finished in 1.291 seconds with exit status 0 (successful).
INFO [a0e618f0] Running ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile on 54.200.196.1
DEBUG [a0e618f0] Command: cd /var/www/html/SparkMyInterest/releases/20131122204608 && ( RAILS_ENV=production ~/.rvm/bin/rvm ruby-2.0.0-p247 do rake assets:precompile )
DEBUG [a0e618f0] /home/ec2-user/.rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
DEBUG [a0e618f0] :
DEBUG [a0e618f0] Could not find ansi-1.4.3 in any of the sources
DEBUG [a0e618f0] (
DEBUG [a0e618f0] Bundler::GemNotFound
DEBUG [a0e618f0] )
Clearly it looks like bundler was run (and successful!). What gives?
Here's my cap file:
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
And in my production.rb (I'm deploying with production) at the top I have:
set :stage, :production
set :rails_env, "production"
Any ideas why bundler isn't working? And/ or why it never seems to install all the required gems?
Thank you a million
I've worked through similar issues with rvm involved (required rvm/capistrano) by providing some additional info to capitrano
set :bundle_cmd, '/path/to/project/rvm/bundle'
set :default_shell, :bash
set :rvm_type, :system
set :rvm_ruby_string, release_path
This code was in my stage-specific deploy (e.g., deploy/production.rb). The issue that I had to work around was that the bundle was installed but to the wrong place; could be what you're facing here as well.
FWIW, rvm/capsitrano also let me specify a shell to use when running certain commands within the deploy script. For example, I was using the whenever gem to update my crontab and needed the "rvm_shell" (my specific ruby with gemset) to make this happen from capistrano. The line looks like this:
run "cd #{release_path} && bundle exec whenever -w -s environment=production", shell: fetch(:rvm_shell)

Resources