Capistrano 3: incompatible ruby version - ruby-on-rails

I am deploying a rails app to Ubuntu 14.04 using Capistrano.
In remote Ubuntu server it shows I am using Ruby 2.3.0
I tried these commands to install Ruby
rbenv install 2.3.0
rbenv global 2.3.0
rbenv rehash
deploy#ubuntu:~$ rbenv versions
system
* 2.3.0 (set by /home/deploy/.rbenv/version)
deploy#ubuntu:~$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
But when I try cap production deploy, error happens and shows a different Ruby is working, instead of 2.3.0
activesupport-5.0.0.1 requires ruby version >= 2.2.2, which is
incompatible with
the current version, ruby 1.9.3p484
How can I fix this?

Related

change ruby version with rbenv

I have just installed rbenv and try to use it, I have unistalled rvm.
I am now trying to use 2.3.3 version of ruby.
rbenv local
2.3.3
rbenv global
2.3.3
ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

Rails using a different version of Ruby from the rest of the sytem?

My installation of Rails seems to be using a different version of Ruby from the version of Ruby on the rest of my system:
$ rails --version
Rails 5 requires Ruby 2.2.2 or newer.
You're running
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
Please upgrade to Ruby 2.2.2 or newer to continue.
$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Why is this? I installed Rails with sudo gem install rails. I'm on OSX and don't remember how I installed Ruby.
Mac OSX comes ruby installed as default. If you need more late versions of ruby, you need to follow this guide: http://railsapps.github.io/installrubyonrails-mac.html

How to change ruby current version by using Capistrano?

We are using ruby version 1.8.7 in our staging server but we need to have ruby 2.4.0 to install rails 5.0. We have installed both versions of ruby, i.e., ruby 1.8.7 and 2.4.0 by RVM through Capistrano.
We have tried to change the ruby version from 1.8.7 to 2.4.0 to install rails 5.0.
But the problem is the ruby version does not change to 2.4.0.
Capistrano version: 2.15.4.
What do we need to do to change the ruby version to 2.4.0 and install Rails 5.0 in staging by Capistrano?

After installing ruby 2.2.3 with rbenv it has a different version

I'm trying to use Rails 5, which requires Ruby version >= 2.2.2.
I installed 2.2.3 with rbenv install 2.2.3 and set it global. When I check with ruby -v I get ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15].
However when I run bundle exec railties/exe/rails new /parent-folder/api --api --edge I get the error:
Rails 5 requires Ruby 2.2.2 or newer.
You're running
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin14.0]
If I explicitly set the local version to the exact version number 2.2.3p173 or 2.2.3 then it says rbenv: version '2.2.3' is not installed (or 2.2.3p173 accordingly).
When I perform rbenv install -l to check available versions only 2.2.3 is listed, not the 2.2.3p173.
Don't understand how to get this to work.
Side notes: I have updated ruby build, my $PATH has rbenv setup correctly, I don't have rvm installed.
Instead of bundle exec railties/exe/rails new /parent-folder/api --api --edge try ./rails/railties/exe/rails new myapp --edge --dev where 'rails' is the rails git repo.

Capistrano 3 deploys a wrong ruby version

On my production machine
rbenv versions
system
* 2.2.2 (set by /Users/smi/.rbenv/version)
which unicorn
/Users/smi/.rbenv/shims/unicorn
ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin12.0]
On my server (I can not understand why unicorn gets ruby version 2.2.0 after a deploy and where from, because is not installed on any of my machines):
rbenv versions
* 2.2.2 (set by /home/deployuser/.rbenv/version)
bundle exec which unicorn
/var/www/foreignernetwork/shared/bundle/ruby/2.2.0/bin/unicorn
.rbenv/version
2.2.2
It is not getting a different version of Ruby. You're running 2.2.2, but Bundler just uses a 2.2.0 directory for storing the bundled gems, bins, etc.

Resources