Bundler requires different ruby version on deploying with Capistrano - ruby-on-rails

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 ?

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

How do I change the bundler called in Capistrano 3?

I am deploying in a multiuser, multiserver environment (Site5).
I am deploying a rails 4 app. The default environment is ruby 1.8.7, rails 3.0.
There is access to local versions of ruby,
Things are working until the bundler is called.
Here's the error snippet:
INFO [4439d586] Running /usr/bin/env bundle install --path /home/username/apps/todos/shared/bundle --without development test --deployment --quiet as username#dirktaylor.ca
DEBUG [4439d586] Command: cd /home/username/apps/todos/releases/20160121174533 && ( export RUBY_BIN_PATH="/usr/local/ruby20/bin" PATH="/usr/local/ruby20/bin:/usr/username/ruby/gems/gems/bundler-1.11.2/exe:$PATH" ; /usr/bin/env bundle install --path /home/username/apps/todos/shared/bundle --without development test --deployment --quiet )
DEBUG [4439d586] Gem::InstallError: i18n requires Ruby version >= 1.9.3.
DEBUG [4439d586] An error occurred while installing i18n (0.7.0), and Bundler cannot continue.
Make sure that `gem install i18n -v '0.7.0'` succeeds before bundling.
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as username#dirktaylor.ca: bundle exit status: 5
bundle stdout: Gem::InstallError: i18n requires Ruby version >= 1.9.3.
An error occurred while installing i18n (0.7.0), and Bundler cannot continue.
Make sure that `gem install i18n -v '0.7.0'` succeeds before bundling.
bundle stderr: Nothing written
As you can see, I am setting environment variables before the bundle command is called.
So, here's what I've figured...
Because Capistrano 3 is executing everything with /usr/bin/env and /usr/bin/env bundle install ... in particular, it is not finding the correct version of bundler to use.
username#dirktaylor.ca [~2]# /usr/bin/env bundle -v;whereis bundle
Bundler version 1.2.1
bundle: /usr/bin/bundle
(Note: /usr/bin/env is linked to /bin/env )
I have installed the current user of bundler (gem install bundler) which is now in ~/ruby/gems/gems/bundler-1.11.2 with executable script at ~/ruby/gems/gems/bundler-1.11.2/exe/bundle
So? Now What?
1) How can I get this version of bundler to execute?
2) Also, inside the script it calls #!/usr/bin/env ruby. Should I change this to the correct ruby path?
3) I saw this solution for Cap 2 elsewhere:
set :bundle_cmd, "/usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle"
set :bundle_dir, "/usr/username/ruby/gems/gems/bundler-1.11.2"
So the question remains: How do I change the bundler called in Capistrano 3?
(Finally: Can this be solved without rvm?)
In Capistrano 3 there is a concept of a "command map" that lets you override the string used for any arbitrary command. In the case you want to map bundle to /usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle, let's say.
You do that like this:
# Put this in deploy.rb or production.rb, etc.
SSHKit.config.command_map[:bundle] = "/usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle"

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

Resources