Deploying capistrano fails by ssh error when running `bundle install` - ruby-on-rails

I'm using Capistrano 3 to deploy a Rails project to VPS server(CentOS 6.5).
Last time about 2 month ago I could deploy without problem, but now I can't deploy by ssh error when running bundle install at the VPS server.
I updated ruby version 2.0.0-p451 to 2.1.1, but it doesn't change error message.
This is the error messages:
INFO[057e025d] Running RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 /usr/local/rbenv/bin/rbenv exec bundle install --binstubs /var/www/example.com/shared/bin --path /var/www/example.com/shared/bundle --without development test --deployment --quiet on example.com
DEBUG[057e025d] Command: cd /var/www/example.com/releases/20140823122915 && ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 /usr/local/rbenv/bin/rbenv exec bundle install --binstubs /var/www/example.com/shared/bin --path /var/www/example.com/shared/bundle --without development test --deployment --quiet )
DEBUG[057e025d] Gem::RemoteFetcher::FetchError: Errno::ETIMEDOUT: Connection timed out - connect(2) for "au-m.rubygems.org" port 443 (https://rubygems.org/gems/rake-10.3.2.gem)
DEBUG[057e025d] An error occurred while installing rake (10.3.2), and Bundler cannot continue.
DEBUG[057e025d] Make sure that `gem install rake -v '10.3.2'` succeeds before bundling.
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host example.com: bundle exit status: 5
bundle stdout: Nothing written
bundle stderr: Nothing written
SSHKit::Command::Failed: bundle exit status: 5
bundle stdout: Nothing written
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: #<SSHKit::Runner::ExecuteError: Exception while executing on host example.com: bundle exit status: 5
bundle stdout: Nothing written
bundle stderr: Nothing written
I could install rake (10.3.2) by # gem install rake at the server manually like this:
rake's executable "rake" conflicts with /usr/local/rbenv/versions/2.1.1/bin/rake
Overwrite the executable? [yN] y
Successfully installed rake-10.3.2
Parsing documentation for rake-10.3.2
Installing ri documentation for rake-10.3.2
Done installing documentation for rake after 2 seconds
1 gem installed
But even after updating the deploy error persists same.
What should I do to remove the error?
Any suggestions are appreciated.

It looks like the server "au-m.rubygems.org" was down.
That was the reason of the error.

Related

Can't deploy with Capistrano - Issue with Capistrano rvm and bundler

Hi to everyone and thank you for coming to help, here is the issue, im trying to deploy a website with capistrano, the gems and dependencies where too updated so i had to update a lot of this website but no matter what i do i always get this error when trying to do a deploy with Bundle exec cap production deploy. Im using a AWS EC2 Ubuntu 16.04 server
I already did a reinstall of bundler, reinstall of ruby, restarted my terminal, capistrano/rvm and capistrano/bundler is added and required on Capfile
00:11 bundler:install
01 ~/.rvm/bin/rvm do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet
#<Thread:0x00000000017b12a8#/home/ubuntu/.rvm/gems/ruby-2.5.3#catalogIndustry/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /home/ubuntu/.rvm/gems/ruby-2.5.3#catalogIndustry/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/home/ubuntu/.rvm/gems/ruby-2.5.3#catalogIndustry/gems/sshkit-1.19.1/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as web#ec2-52-15-226-151.us-east-2.compute.amazonaws.com: bundle exit status: 1 (SSHKit::Runner::ExecuteError)
bundle stdout: `rvm do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` was removed, use `rvm 1.9.2,1.9.3 do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` or `rvm all do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` instead.
bundle stderr: Nothing written
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as web#ec2-52-15-226-151.us-east-2.compute.amazonaws.com: bundle exit status: 1
bundle stdout: `rvm do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` was removed, use `rvm 1.9.2,1.9.3 do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` or `rvm all do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` instead.
bundle stderr: Nothing written
Caused by:
SSHKit::Command::Failed: bundle exit status: 1
bundle stdout: `rvm do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` was removed, use `rvm 1.9.2,1.9.3 do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` or `rvm all do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` instead.
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 web#ec2-52-15-226-151.us-east-2.compute.amazonaws.com: bundle exit status: 1
bundle stdout: `rvm do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` was removed, use `rvm 1.9.2,1.9.3 do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` or `rvm all do bundle install --path /home/web/apps/catalog/shared/bundle --jobs 4 --without development test --deployment --quiet` instead.
bundle stderr: Nothing written
** DEPLOY FAILED
** Refer to log/capistrano.log for details.
What else can i do to resolve this error and deploy the website?
Seems that Capistrano can't determine correct RVM ruby version. You can point it by hand
# deploy.rb
set :rvm_ruby_version, '2.5.3'
# or if you have single ruby version
set :rvm_ruby_version, 'default'

Bundle not found when deploying to gcloud

I'm deploying a rails app to Google Cloud App Engine. Since adding
config.action_mailer.default_url_options = { host: 'foobar.appspot.com'}
to production.rb, the build fails on deploy. Here are the logs:
INFO[0108] RUN bundle install --deployment --without="development test" && rbenv rehash
INFO[0108] cmd: /bin/sh
INFO[0108] args: [-c bundle install --deployment --without="development test" && rbenv rehash]
/bin/sh: 1: bundle: not found
error building image: error building stage: waiting for process to exit: exit status 127
There are 2 options, which you should to try:
Change bundle to bundler.
install bundler manually with something like gem install bundler -v 1.17.1

Json -v 1.8.6 will not install as part of capistrano deploy

This question has been asked a couple of times on stackoverflow and other forums but I can't seem to get passed this error that I am getting. When I run capistrano production deploy, I get this error as part of the deploy process.
cap production bundler:install
00:00 bundler:install
01 bundle install --path /var/local/blackduck_flock_rails/shared/bundle --without development test --deployme…
01 An error occurred while installing json (1.8.6), and Bundler cannot continue.
01 Make sure that `gem install json -v '1.8.6'` succeeds before bundling.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as serv-deployer#oh-utility01.dc1.lan: bundle exit status: 5
bundle stdout: An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling.
bundle stderr: Nothing written
Tasks: TOP => bundler:install
(See full trace by running task with --trace)
I've taken a look at my log/capistrano.log file and here are the relevant contents that I was looking at to trouble shoot.
# Logfile created on 2017-05-03 14:42:16 -0400 by logger.rb/54072
INFO ---------------------------------------------------------------------------
INFO START 2017-05-03 14:42:16 -0400 cap production bundler:install
INFO ---------------------------------------------------------------------------
DEBUG [ec1d281e] Running if test ! -d /var/local/blackduck_flock_rails/current; then echo "Directory does not exist '/var/local/blackduck_flock_rails/current'" 1>&2; false; fi as serv-deployer#oh-utility01.dc1.lan
DEBUG [ec1d281e] Command: if test ! -d /var/local/blackduck_flock_rails/current; then echo "Directory does not exist '/var/local/blackduck_flock_rails/current'" 1>&2; false; fi
DEBUG [ec1d281e] Finished in 0.328 seconds with exit status 0 (successful).
DEBUG [4f633904] Running /usr/bin/env bundle check --path /var/local/blackduck_flock_rails/shared/bundle as serv-deployer#oh-utility01.dc1.lan
DEBUG [4f633904] Command: cd /var/local/blackduck_flock_rails/current && /usr/bin/env bundle check --path /var/local/blackduck_flock_rails/shared/bundle
DEBUG [4f633904] Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
DEBUG [4f633904] The following gems are missing
* json (1.8.6)
* tzinfo (1.2.2)
* activesupport (4.2.6)
etc. etc..........
DEBUG [4f633904] * uglifier (3.0.4)
DEBUG [4f633904] Install missing gems with `bundle install`
DEBUG [4f633904] Finished in 0.179 seconds with exit status 1 (failed).
INFO [6c99e662] Running /usr/bin/env bundle install --path /var/local/blackduck_flock_rails/shared/bundle --without development test --deployment --quiet as serv-deployer#oh-utility01.dc1.lan
DEBUG [6c99e662] Command: cd /var/local/blackduck_flock_rails/current && /usr/bin/env bundle install --path /var/local/blackduck_flock_rails/shared/bundle --without development test --deployment --quiet
DEBUG [6c99e662] An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6'` succeeds before bundling.
So the first thing to note. The log is telling me that the running version of bundler is out of date and that I should install the newest one. Here is what I don't understand though. On my developing machine, I have Bundler version 1.14.6. On the targeting server that I am trying to deploy to, I also have Bundler version 1.14.6. I've confirmed it on both machines and they are indeed the same. Second, I have the same ruby versions for both developing machine and target machine. The ruby version is 2.2.5.
Second, when I run gem list on the target server, I can see that json 1.8.6 is installed.
json (1.8.3, 1.8.1)
What gives?
Finally, the problem has to be in this directory on the target machine /var/local/blackduck_flock_rails/shared/bundle. Inside the bundle directory, I have a ruby folder that has 1.9.1 and 2.2.0. Could this be the source of the problem. I'm stumped on this one and it seems that questions like these always relate to something specific on someone's machine that won't necessarily be applied. Help would be greatly appreciated.
The most probable cause is you're missing some system dependencies that capistrano cannot install.
Ssh to your server and try installing sudo apt-get install libgmp3-dev
If it doesn't fix the problem, ssh again and run the gem install json -v '1.8.6' as it tells you and post the error message you get from it here.

Bundler requires different ruby version on deploying with Capistrano

I defined ruby version 2.0.0-p645 in .ruby_version file
cap production deploy stops with bundler error:
INFO [11dd01a8] Running /usr/local/rvm/bin/rvm default do bundle install --path /var/www/p4-site/shared/bundle --without development test --deployment --quiet on p4-ocean
DEBUG [11dd01a8] Command: cd /var/www/p4-site/releases/20160206090913 && /usr/local/rvm/bin/rvm default do bundle install --path /var/www/p4-site/shared/bundle --without development test --deployment --quiet
DEBUG [11dd01a8] ruby-2.0.0-p481 is not installed.
DEBUG [11dd01a8] To install do: 'rvm install ruby-2.0.0-p481'
DEBUG [11dd01a8] /usr/local/rvm/scripts/set: line 19: exec: bundle: not found
(Backtrace restricted to imported tasks)
Gemfile doesn't contain ruby command
.bundle/config file contains
---
BUNDLE_WITHOUT: production
Where does bundler store ruby version 2.0.0-p481 ?

Capistrano deploy fails when upgrade ruby version in rbenv

When I run cap production deploy in my rails project directory, I get error like this:
INFO[6be9dff4] Running RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 /usr/local/rbenv/bin/rbenv exec bundle install --binstubs /var/www/example.com/shared/bin --path /var/www/example.com/shared/bundle --without development test --deployment --quiet on example.com
DEBUG[6be9dff4] Command: cd /var/www/example.com/releases/20140624143014 && ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 /usr/local/rbenv/bin/rbenv exec bundle install --binstubs /var/www/example.com/shared/bin --path /var/www/example.com/shared/bundle --without development test --deployment --quiet )
DEBUG[6be9dff4] Errno::EACCES: Permission denied # rb_sysopen - /var/www/example.com/shared/bundle/ruby/2.1.0/cache/rake-10.3.2.gem
DEBUG[6be9dff4] An error occurred while installing rake (10.3.2), and Bundler cannot continue.
DEBUG[6be9dff4] Make sure that `gem install rake -v '10.3.2'` succeeds before bundling.
So I login server and change user to deploy user, then run command like this:
$ su - deployer
Password:
deployer#server ~$ cd /var/www/example.com/releases/20140624143014 && ( RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 RBENV_ROOT=/usr/local/rbenv RBENV_VERSION=2.1.1 /usr/local/rbenv/bin/rbenv exec bundle install --binstubs /var/www/example.com/shared/bin --path /var/www/example.com/shared/bundle --without development test --deployment --quiet )
Errno::EACCES: Permission denied # rb_sysopen - /var/www/example.com/shared/bundle/ruby/2.1.0/cache/rake-10.3.2.gem
An error occurred while installing rake (10.3.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.3.2'` succeeds before bundling.
rbenv and ruby is installed like this:
$ rbenv versions
system
2.0.0-p451
* 2.1.1 (set by /usr/local/rbenv/version)
I'm tring to deploy from LinuxMint16 to CentOS 6.5 with Capistrano 3 and prior deploy was successful when I used 2.0.0-p451.
How and what should I check to find out what causes error?

Resources