Can't deploy with Capistrano - Issue with Capistrano rvm and bundler - ruby-on-rails

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'

Related

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 ?

Deploying capistrano fails by ssh error when running `bundle install`

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.

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?

How to solve Some gems seem to be missing from your vendor/cache directory. Could not find "whatever" in any of the sources?

This is driving me crazy. I added a gem (hirb) to the Gemfile and now I can't deploy.
Yes, I used bundle install --path vendor/cache
Yes I used bundle package
Yes I committed Gemfile and Gemfile.lock
I deleted the vendor/cache folder in the production machine so it would generate it again instead of updating it. Was this wrong?
Whenever I run cap:deploy I get the following...
executing "cd /var/www/releases/20120606002321 && bundle install --gemfile /var/www/releases/20120606002321/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test"
servers: ["11.111.11.11"]
[11.111.11.11] executing command
[11.111.11.11] env PATH=/var/lib/gems/1.9.1/bin:$PATH sh -c 'cd /var/www/releases/20120606002321 && bundle install --gemfile /var/www/releases/20120606002321/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test'
** [out :: 11.111.11.11] Some gems seem to be missing from your vendor/cache directory.
** [out :: 11.111.11.11] Could not find multi_json-1.3.6 in any of the sources
command finished in 48571ms
*** [deploy:update_code] rolling back
* executing "rm -rf /var/www/releases/20120606002321; true"
servers: ["11.111.11.11"]
[11.111.11.11] executing command
[11.111.11.11] env PATH=/var/lib/gems/1.9.1/bin:$PATH sh -c 'rm -rf /var/www/releases/20120606002321; true'
command finished in 6417ms
failed: "env PATH=/var/lib/gems/1.9.1/bin:$PATH sh -c 'cd /var/www/releases/20120606002321 && bundle install --gemfile /var/www/releases/20120606002321/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test'" on 11.111.11.11
You might want to try removing the --deployment flag. That seems to allow Bundler to install from both the vendor/cache source and Rubygems.
Capfile:
set :bundle_flags, "--quiet --no-cache"
A related bug: https://github.com/bundler/bundler/issues/1454
Try,
bundle install --no-deployment
This removes the --deployment "bundle freeze" that prevents updates you're attempting. You can verify a freeze is imposed by looking for BUNDLE_FROZEN in .bundle/config
#leonel, there are several things you can check:
See if you have the correct source to get the gems from (source "http://rubygems.org")
Try to do a gem install multi_json
Take a look at the log files of your web server. They help a lot in cases like this one when you use common weapons an cannot hit the target.
Later you should check if you have an older version, then try to update using gem, to the required (or latest) version of multi_json.
Hope that helps,
R

Rails 3. Could not find libv8-3.3.10.4 in any of the sources

I'm trying to run cap deploy for the first time but I get this error...
[11.12.13.140] sh -c 'cd /var/www/releases/20120302151641 && bundle install --gemfile /var/www/releases/20120302151641/Gemfile --path /var/www/shared/bundle --deployment --quiet --without development test'
** [out :: 11.12.13.140] Some gems seem to be missing from your vendor/cache directory.
** [out :: 11.12.13.140] Could not find libv8-3.3.10.4 in any of the sources
I have this on my Gemfile gem 'libv8', '3.3.10.4'
I packaged my gems in the vendor/cache directory and I do have this gem libv8-3.3.10.4-x86_64-linux
Why do I keep on getting this error? How can I fix it?
Do gem install --version '=3.3.10.4' libv8 on the target machine.
Are you sure you need packaging? Capistrano does bundle install for me, so I just did
rm -rf vendor/cache
bundle install
and problem gone because now gems compiled on the target machine.
If you still need packaging see this question for fine-grainded solution.
If your local environment is different to your production environment, the easiest is to download the version you need for your production environment from:
https://rubygems.org/gems/libv8/versions
Save it into your vendor/cache directory.

Resources