Can't get Capistrano to call bundle and rake commands - ruby-on-rails

I can't get Capistrano to run bundle commands and rake commands.
I get debug logs like this:
DEBUG [0f557e7e] /usr/bin/env: bundle
DEBUG [0f557e7e] : No such file or directory
I have RVM on all ma computers (dev and production)
Here's my config:
deploy.rb
lock '3.1.0'
set :application, 'blog'
set :repo_url, 'git#github.com:xxx/yyyy.git'
set :deploy_to, '/home/joel/apps/blog'
set :deploy_via, :copy
set :rvm_ruby_version, '2.1.0p0'
set :default_env, { rvm_bin_path: '/home/joel/.rvm/bin:$PATH' }
SSHKit.config.command_map[:rake] = "#{fetch(:default_env)[:rvm_bin_path]}/rvm ruby-#{fetch(:rvm_ruby_version)} do bundle exec rake"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end
desc 'Migrate db'
task :migrate do
on primary :db do
within release_path do
execute :rake, 'db:migrate'
end
end
end
desc 'Bundle install'
task :bundle do
on primary :app do
within release_path do
execute :bundle, 'install'
end
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
production.rb
role :app, %w{xxx#yyy.com}
role :web, %w{xxx#yyy.com}
role :db, %w{xxx#yyy.com}
server 'yyy.com', user: 'xxx', roles: %w{web app}, my_property: :my_value
capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
and when I try to call
cap production deploy:bundle
if I want to call bundle:install on the production server, here's what I get :
INFO [0f557e7e] Running /usr/bin/env bundle install on yyy.com
DEBUG [0f557e7e] Command: cd /home/joel/apps/blog/current && ( RVM_BIN_PATH=/home/joel/.rvm/bin:$PATH /usr/bin/env bundle install )
DEBUG [0f557e7e] /usr/bin/env: bundle
DEBUG [0f557e7e] : No such file or directory
Although, if I ssh onto the server and copy-paste that command, it works fine. (and the same thing happens with take commands, like rake db:migrate). I'm pretty sure it has something to do with the paths, so here's my
rvm info
ruby-2.1.0:
system:
uname: "Linux li101-172 3.12.6-x86_64-linode36 #2 SMP Mon Jan 13 18:54:10 EST 2014 x86_64 x86_64 x86_64 GNU/Linux"
system: "ubuntu/12.04/x86_64"
bash: "/bin/bash => GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)"
zsh: "/usr/bin/zsh => zsh 4.3.17 (x86_64-unknown-linux-gnu)"
rvm:
version: "rvm 1.25.14 (stable) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "15 days 19 hours 42 minutes 40 seconds ago"
path: "/home/joel/.rvm"
ruby:
interpreter: "ruby"
version: "2.1.0p0"
date: "2013-12-25"
platform: "x86_64-linux"
patchlevel: "2013-12-25 revision 44422"
full_version: "ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]"
homes:
gem: "/home/joel/.rvm/gems/ruby-2.1.0"
ruby: "/home/joel/.rvm/rubies/ruby-2.1.0"
binaries:
ruby: "/home/joel/.rvm/rubies/ruby-2.1.0/bin/ruby"
irb: "/home/joel/.rvm/rubies/ruby-2.1.0/bin/irb"
gem: "/home/joel/.rvm/rubies/ruby-2.1.0/bin/gem"
rake: "/home/joel/.rvm/rubies/ruby-2.1.0/bin/rake"
environment:
PATH: "/home/joel/.rvm/gems/ruby-2.1.0/bin:/home/joel/.rvm/gems/ruby-2.1.0#global/bin:/home/joel/.rvm/rubies/ruby-2.1.0/bin:/home/joel/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
GEM_HOME: "/home/joel/.rvm/gems/ruby-2.1.0"
GEM_PATH: "/home/joel/.rvm/gems/ruby-2.1.0:/home/joel/.rvm/gems/ruby-2.1.0#global"
MY_RUBY_HOME: "/home/joel/.rvm/rubies/ruby-2.1.0"
IRBRC: "/home/joel/.rvm/rubies/ruby-2.1.0/.irbrc"
RUBYOPT: ""
gemset: ""
edit:
I also tried removing all paths, and using PermitUserEnvironment in ~/.ssh/environment
and changing my task to loo
desc 'Bundle install'
task :bundle do
on primary :app do
within release_path do
execute 'source ~/.zshrc && cd ~/apps/blog/current/ && bundle install'
execute 'source ~/.zshrc && cd ~/apps/blog/current/ && RAILS_ENV=production rake db:migrate'
execute 'source ~/.zshrc && cd ~/apps/blog/current/ && RAILS_ENV=production rake assets:precompile'
end
end
end
and it works. So the problem was really with the paths, but is there a way to use symbols to avoid using the source and cd ?

I ended up reinstalling RVM and my path problems were solved. I still don't know why it works, but it works.

Related

Error bash: bundle: command not found while cap deploy:cold

I am using this_link for deploying, but I didnt created new user rather I am continuing with root user. I am using unicorn, nginx, capistrano for this.
On running cap deploy:cold, I am getting error bash: bundle: command not found.
deploy.rb
set :stages, %w(production) #various environments
require "bundler/capistrano"
require "rvm/capistrano"
server "xxx.xxx.xxx.xx", :web, :app, :db, primary: true
set :application, "xyz"
set :stage, "production"
set :user, "root"
set :port, 22
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :default_shell, :bash
# set :scm, "git"
set :repository, "git#bitbucket.org:xyz_app/xyz.git"
set :branch, "master"
# set :rvm_ruby_string, :local # use the same ruby as used locally for deployment
set :rvm_autolibs_flag, "read-only" # more info: rvm help autolibs
before 'deploy:setup', 'rvm:install_rvm' # install/update RVM
# before 'deploy:setup', 'rvm:install_ruby'
# before 'deploy:setup', 'rvm:install_ruby' # install Ruby and create gemset,
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 the config files in #{shared_path}."
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
cap shell output
cap> echo $PATH
[establishing connection(s) to xxx.xxx.xxx.xx]
** [out :: xxx.xxx.xxx.xx] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/.rvm/bin
** [out :: xxx.xxx.xxx.xx]
cap> id
** [out :: xxx.xxx.xxx.xx] uid=0(root) gid=0(root) groups=0(root)
** [out :: xxx.xxx.xxx.xx]
cap> exit
cap deploy:check
You appear to have all necessary dependencies installed
Error code
* 2015-09-10 01:49:10 executing `bundle:install'
* executing "cd /home/root/apps/xyz/releases/20150909201909 && bundle install --gemfile /home/root/apps/xyz/releases/20150909201909/Gemfile --path /home/root/apps/xyz/shared/bundle --deployment --quiet --without development test"
servers: ["xxx.xxx.xxx.xx"]
[xxx.xxx.xxx.xx] executing command
** [out :: xxx.xxx.xxx.xx] bash: bundle: command not found
** [out :: xxx.xxx.xxx.xx]
command finished in 338ms
*** [deploy:update_code] rolling back
Please help me out from this issue. Thanks in advance
You need bundler. http://bundler.io/
gem install bundler
This gave it away: bash: bundle: command not found

Capistrano doesn't install

Whenever I try to run cap production deploy it fails at the following command
[ebbf9fde] Command: cd /var/www/apps/my_app/releases/20150803171251 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/my_app/shared/bundle --without development test --deployment --quiet
DEBUG [ebbf9fde] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
I have a added a user 'deploy' to do this deployment, the ouput of rvm list is
$ rvm list
rvm rubies
=* ruby-2.2.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Further running gem list the output is
$ gem list
*** LOCAL GEMS ***
bigdecimal (1.2.6)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
gem-wrappers (1.2.7)
io-console (0.4.3)
json (1.8.1)
minitest (5.4.3)
passenger (5.0.15)
power_assert (0.2.2)
psych (2.0.8)
rack (1.6.4)
rake (10.4.2)
rdoc (4.2.0)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
test-unit (3.0.8)
My Capfile contents are
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
Finally my deploy.rb contains the following data.
lock '3.4.0'
set :app_host, 'ip-address-here'
set :application, 'my_app'
set :repo_url, 'git#example.com:<not_right>/my_app.git'
set :rvm_type, :system
set :rvm_ruby_version, '2.2.2'
set :passenger_rvm_ruby_version, '2.2.2'
set :rbenv_ruby, '2.2.2'
set :deploy_to, '/var/www/apps/my_app'
set :scm, :git
set :format, :pretty
set :log_level, :debug
set :pty, true
set :conditionally_migrate, true
set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
set :keep_releases, 5
set :migrate_env, "#{ fetch(:stage) }"
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:web), in: :sequence, wait: 5 do
execute :mkdir, '-p', release_path.join('tmp')
execute :touch, release_path.join('tmp/restart.txt')
end
end
task :httpd_graceful do
on roles(:web), in: :sequence, wait: 5 do
execute :sudo, "service httpd graceful"
end
end
after :publishing, :restart
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
namespace :deploy_prepare do
desc 'Configure virtual host'
task :create_vhost do
on roles(:web), in: :sequence, wait: 5 do
vhost_redirect_config = <<-EOF
Redirect permanent /#{ fetch(:application) } http://#{ fetch(:app_host) }/#{ fetch(:application) }/
EOF
vhost_location_config = <<-EOF
Alias /#{fetch(:application)} #{fetch(:deploy_to)}/current/public
<Location /#{fetch(:application)}>
PassengerBaseURI /#{ fetch(:application) }
PassengerAppRoot #{ fetch(:deploy_to) }/current/
PassengerRuby /usr/local/rvm/wrappers/ruby-#{ fetch(:rvm_ruby_version) }/ruby
RailsEnv #{ fetch(:stage) }
</Location>
<Directory #{ fetch(:deploy_to) }/current/public >
Allow from all
Options -MultiViews
</Directory>
EOF
execute :echo, "\"#{ vhost_redirect_config }\"", ">", "/etc/httpd/conf.d/redirects/#{ fetch(:application) }.conf"
execute :echo, "\"#{ vhost_location_config }\"", ">", "/etc/httpd/conf.d/apps/#{ fetch(:application) }.conf"
end
end
end
after "deploy:updated", "deploy:cleanup"
after "deploy:finished", "deploy_prepare:create_vhost"
after "deploy_prepare:create_vhost", "deploy:httpd_graceful"
after "deploy:httpd_graceful", "deploy:restart"
I am getting the following error
DEBUG [298e6d4e] Command: cd /var/www/apps/oxygen/releases/20150803172155 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/oxygen/shared/bundle --without development test --deployment --quiet
DEBUG [298e6d4e] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deployer#162.243.131.67: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
SSHKit::Command::Failed: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
Tasks: TOP => deploy:updated => bundler:install
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deployer#162.243.131.67: bundle exit status: 127
bundle stdout: /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
bundle stderr: Nothing written
Just try gem install bundler on the server once to install bundler into the rvm gemset, as its not in the list of your gem list.
In general try to ensure that the bundle command runs when you log into your server via ssh. Capistrano doesn't do magic, it just logs in via ssh and issues commands. You can always see what commands capistrano issues, like in your example cd /var/www/apps/oxygen/releases/20150803172155 && /usr/local/rvm/bin/rvm 2.2.2 do bundle install --path /var/www/apps/oxygen/shared/bundle --without development test --deployment --quiet and try them yourself when something fails.
Be sure you have bundler installed in the correct gemset.
I got this error and was scratching my head because bundler was installed in the default gemset, but it was not in the one I was using for my rails application.
When I realized it I was like, "doh!"
Just thought I would post this here, hopefully it will help someone else.
This didnt work for me, gem install bundler
I realized I didn't set my deploy.rb file correctly.
So because I am using RVM, I checked the rvm list for the ruby version
jruby-1.7.19 [ x86_64 ]
=* ruby-2.2.1 [ x86_64 ]
then config my deploy.rb file to set :rvm_ruby_version, 'ruby-2.2.1'
On your server
rvm 2.2.2#gemset-name do gem install bundler
Source: https://github.com/capistrano/rvm/issues/65#issuecomment-94108188

capistrano deployment unable to bundle install gem with no internet connection

I am deploying my application to a new server which has everything installed.
I am using the following capistrano deploy.rb:
require "capistrano/ext/multistage"
require "bundler/capistrano"
set :default_environment, {
'ORACLE_HOME' => "/opt/oraclient/64/11.2.0.2/",
'LD_LIBRARY_PATH' => "$ORACLE_HOME/lib:/usr/local/lib",
'PATH' => "/opt/ruby/bin:$PATH:$ORACLE_HOME/bin"
}
SECURE_FILES = ['database.yml', 'ldap.yml', 'initializers/secret_token.rb']
set :application, "myapp"
set :use_sudo, false
set :scm, :git
set :repository, "ssh://git#hostname:7999/web/myapp.git"
set :user, "webuser"
set :deploy_via, :remote_cache
after "deploy:update_code", "custom:create_symlinks", "custom:assets_precompile", "custom:miscellaneous"
after "deploy", "deploy:migrate"
after "deploy", "deploy:cleanup"
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails"
task t, :roles => :app do ; end
end
namespace :web do
desc "Enable maintenance mode for apache"
task :enable_maintenance, :role => :web do
run "mkdir -p #{shared_path}/system"
on_rollback { run "rm -f #{shared_path}/system/maintenance.html" }
page = File.read('public/maintenance.html')
put page, "#{shared_path}/system/maintenance.html", :mode => 0644
end
desc "Disable maintenance mode for apache"
task :disable_maintenance, :role => :web do
run "rm -f #{shared_path}/system/maintenance.html"
end
end
end
namespace :custom do
desc "Creating config, bundler-GEMS symlinks"
task :create_symlinks, :roles => :app do
#Secure Configuration File Symlinks
SECURE_FILES.each do |link|
fobj = "#{release_path}/config/#{link}"
run <<-CMD
if [ -e #{fobj} ]; then rm -f #{fobj}; fi;
rm -f #{previous_release}/config/#{fobj};
ln -s #{vormetric_path}/#{application}/#{link} #{fobj};
CMD
end
#Bundler GEM Installation Symlink
shared_bundler_dir = File.join(shared_path, 'bundle')
release_bundler_dir = File.join(current_release, 'vendor/bundle')
run "ln -s #{shared_bundler_dir} #{release_bundler_dir}"
end
desc "Assets Pre-Compilation"
task :assets_precompile, :roles => :app do
run "cd #{current_release} && RAILS_ENV=#{rails_env} bundle exec rake assets:precompile"
end
desc "Miscellaneous Tasks"
task :miscellaneous, :roles => :app do
run "chmod -f +w #{current_release}/db/schema.rb"
end
end
This is box-specific deploy script myhostname.rb:
server "myhostname", :app, :web, :db, :primary => true
set :deploy_to, "/opt/web/var/myapp"
set :rails_env, "customertest"
set :branch, "staging"
Now the remote box does not have access to internet, but I have all my gems stored under vendor/cache. So it should pick up from there.(vendor/cache has nokigiri under /myapp/current/vendor/cache on remote server)
When i run
cap deploy servername
, i get the following error:
** [out :: myhost] An error occurred while installing nokogiri (1.5.9), and Bundler cannot
** [out :: myhost] continue.
** [out :: myhost] Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.
My remote box where the code is supposed to be deployed has the following folders set up:
/opt/web/var/myapp
/opt/web/var/myapp/current(where all the code is cloned currently)
/opt/web/var/myapp/releases
/opt/web/var/myapp/shared
I am not sure how it i supposed to pick up and install the gem.
This quote from bundler docs might be relevant (emphasis mine):
http://bundler.io/v1.9/bundle_package.html
By default, if you simply run bundle install after running bundle package, Bundler will still connect to rubygems.org to check whether a platform-specific gem exists for any of the gems in vendor/cache.
This behavior can be avoided by instead running bundle install --local. Note that this requires you to have the correctly platformed version for all of your gems already cached. The easiest way to achieve this is to run bundle package on an identical machine and then check in those vendored gems.
So, in short, you need to pass the --local flag when running bundler in the production server to avoid connecting to rubygems altogether.
The solution for use with capistrano is to set this variable in you deploy.rb file:
# deployment and quiet are used by default, we add the local flag
set :bundle_flags, "--deployment --quiet --local"

Problems with sudo when deploying RVM with Capistrano

I would like to use Capistrano to deploy my app in my server
I have the deploy.rb file with the following content:
set :user, "deploy"
set :use_sudo, true
set :deploy_to, "/webapps/#{application}"
#set :deploy_via, :remote_cache #Using this option avoids to do a full repository clone
#RVM
set :rvm_type, :system #System Wide installation
set :rvm_ruby_string, 'ree#K2'
set :rvm_install_shell, :bash
before 'deploy:setup','rvm:install_rvm'
before 'deploy:setup', 'rvm:install_ruby'
# 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 "touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
Everything works fine when i set the root user, installs RVM (system-wide installation) and even a Ruby Enterprise, but when I run 'cap deploy:setup' setting the use_sudo option and deploy user, get this:
$ cap deploy:setup
* executing `deploy:setup'
triggering before callbacks for `deploy:setup'
* executing `rvm:install_rvm'
* executing "bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)"
servers: ["myserver.com"]
Password:
[myserver.com] executing command
[myserver.com] bash -c 'bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)'
*** [err :: myserver.com] bash: line 304: /usr/local/rvm/RELEASE: Permission denied
command finished in 564ms
failed: "bash -c 'bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)'" on myserver.com
What I have to do to make this work? Do I have to adjust some settings in sudoers file?
please test with 1.1.0:
gem install rvm-capistrano

Capistrano and Bundler problem - bundle: not found

I keep getting the following error when trying to deploy my app with the bundle/install option:
failed: "sh -c 'cd /home/deploy/swamp/releases/20110903003336
&& bundle install --gemfile /home/deploy/swamp/releases/20110903003336/Gemfile
--path /home/deploy/swamp/shared/bundle --deployment --quiet
--without development test'" on 12.345.678.98
**Update - looks like I missed an error:
[err :: 12.345.678.98] sh: bundle: not found
I've tried this in my deploy.rb:
require "bundler/capistrano"
and I've tried this:
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, '.bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
bundler.create_symlink
run "cd #{release_path} && bundle install --without test"
end
end
after 'deploy:update_code', 'bundler:bundle_new_release'
I've also moved my bundle to the vendor path with this:
bundle install --path vendor/bundle
I don't think it's a permissions problem, because I can log in manually with deploy and bundle install directly on the server no problem. Here is the entire deploy.rb file:
require "bundler/capistrano"
set :application, "swamp"
set :domain, "12.345.678.98"
set :repository, "git#github.com:***/**.git"
set :deploy_to, "/home/deploy/#{application}"
set :rails_env, 'production'
set :branch, "master"
role :app, domain
role :web, domain
role :db, domain, :primary => true
set :deploy_via, :remote_cache
set :scm, :git
set :user, "deploy"
set :runner, "deploy"
ssh_options[:port] = ****
set :use_sudo, false
after "deploy", "deploy:cleanup"
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
end
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails"
task t, :roles => :domain do ; end
end
end
task :after_update_code do
run "ln -nfs #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
end
I found the solution here:
http://www.pastbedti.me/2011/06/change-path-environment-with-rails-and-capistrano/
In you config/deploy.rb add the following snippet
set :default_environment, {
'PATH' => "/opt/ruby-enterprise/bin/:$PATH"
}
Then I had to add gemfile.lock and gemfile to the repository and the BAM!
outdated
the below solution works for capistrano 2. for version 3 and up use the capistrano-rbenv plugin.
assuming you're using the bash shell and have rbenv configured in something along the lines of a bashrc or profile file (globally in /etc or on a user-by-user basis) the problem is that capistrano does not use a so-called login shell which is required to have these files loaded (which, in the end, load rbenv).
for that purpose you might want to instruct capistrano to use such a shell:
default_run_options[:shell] = '/bin/bash --login'
put that into your deploy.rb. also has the benefit of keeping you DRY by not introducing another location to manage your rbenv $PATH additions -- in contrast to fatfrog's solution.
This happens because the bashrc rbenv init doesn't get executed. Move this to the top of your deployer user bashrc file and it will fix the problem:
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
If your Issue is RVM on the server, then look at the help provided by rvm.io:
https://rvm.io/integration/capistrano/#gem
make sure you indeed have the rbenv installed in your server(sounds ridiculous, but it did happen in my case)
use this gem: https://github.com/yyuu/capistrano-rbenv
for more details, see my answer here: https://stackoverflow.com/a/15779928/445908
I was facing this problem and in my case the snippet from deploy/production.rb was as follows:
run "cd #{release_path} && bundle --without development test"
Had to install bundler as follows:
sudo apt-get install bundler

Resources