Commands to keep your app healthy, Ruby and Rails gems wise.
Open new Terminal, note the gemsets showing:
rvm gemset list
You will see you are using the (default) gemset.
Keep your system up to date with rvm
and brew
:
rvm get stable
brew update
: will update your Homebrew (takes a while):
brew doctor
: check to make sure all is well
rvm list known
: Ref : Rubies rvm knows about and can install
The part you are most interested in this day in Feb 2020 reads as:
[ruby-]2.2[.7]
[ruby-]2.4[.9]
[ruby-]2.5[.7]
[ruby-]2.6[.5]
[ruby-]2.7[.0]
ruby-head
Which version of Ruby to use with which version of Rails ??
Rubygems Rails Versions
Click on your version, and check its requirements.
Now, check your ruby version, just so you know,
upgrading command comes later, make no change to ruby yet.
ruby -v
Run these:
rvm gemset list
: should be on global.
rvm gemset use global
: if you are somehow out of the => global gemset.
gem update --system
gem update rake
gem update bundler
gem update rubygems-bundler
gem outdated
A VALID NOTE from stackoverflow
"Don't ever use 'bundle update' or 'gem update' arbitrarily. That's like saying
"give me the newest versions of all gems from all available sources" without knowing
the effects beforehand. It can be a Pandora's Box of trouble if you aren't careful,
especially 'bundle update'."
The solution to this problem causer is to update gems one at a time, and run tests.
This method lets you easily check each Gem's upgrades as you go along, and prevents
your being overwhelmed with breaks in your app. When you have tests in place covering
your code, finding the causes of those breaks becomes easy peasy lemon squeezey.
EXAMPLE:
bundle update selenium-webdriver
: and then run your tests, to check.
bundle update launchy
: and then run tests that use Launchy, to check.
Because we are in the => global gemset, I always do the gem update.
Verify with:
rvm list known
gem update
: updates only the global gemset gems
Now we install Ruby ..
rvm install 2.5.7
: adjust versions as needed if Gist not current to latest Ruby or Rails versions.
rvm use ruby-2.5.7
: a new entity, needs a few things to work ..
or ..
rvm --default use ruby-2.5.7
*: if you want to use 2.5.7 from now on.
Now we install rails into the new entity, the new ruby container.
We are in the global
gemset. How do you know ??
Run ..
rvm gemset list
gem install rails -v 4.2.11.1
: now Ruby 2.5.7 has Rails 4.2.11.1
To better underdstand this process, I referred to these instructions: Rails <=> Ruby Verisions
Now we add into the Ruby 2.5.7 container its new bundler:
gem install bundler
bundle install
: to install all other Ruby version project gems
Next we update Rails and it is important to do this every time you upgrade Rails versions.
rake rails:update
If the process asks you if you want to overwrite a file, type in
d
for diff
and it will show you the changes it is about to make.
If you have working code in your file that cannot be overwritten,
and yet there is new code to be added, simply open the file it wants to overwrite,
and make those additions by hand, save the file, close it,
and choose n
: do not allow the overwrite. That preserves your code and adds new.
An example is if you are using the Spring gem, you will see codes with /spring/ in the
bin file overwrite question, after you type in d
for diff
..
Do not allow overwrite of spring codes in the bin/files.
Now we Change Directory into your app ..
cd your_application_name
rvm gemset list
: still on => global
open -e Gemfile
: change Ruby version
open -e .ruby-version
: change Ruby version
open -e .ruby-gemset
: change Ruby version
rvm use 2.5.7
: sets Terminal to 2.5.7 immediately
We are still using global gemset.
We now create new gemset for the app, for first time creation use:
rvm gemset use Rails4.2_your_app_name --create --default
With above command used once, below is never needed:
rvm gemset use Rails4.2_app_name
For the first time use, we will add the create and default switches.
rvm gemset use Rails4.2 _app_name --create --default
Run this command again, you will see the gemset is being used:
rvm gemset list
You just created and are now using the application's gemset.
The --default
switch will cause this gemset to be used when
you first enter the app directory. At this point, I personally
like to close that terminal window and open a new one, and watch
the rvm magic show itself as it recognizes the new gemset.
If you ever change gemsets, the use
command is the way back.
However, at this point, when you change directory into this app,
the .ruby-gemset
file will be used to set the correct gemset.
You can use the command to change gemsets and change back:
rvm gemset use Rails4.2_app_name
To upgrade your rails version, do this:
open -e Gemfile
: Change Rails version to upgrade version
gem install rails --version 4.2.11.1
Continuing, no matter your Rails version or gem install:
ruby -v
rails -v
If all is well on rails response, skip down to
bundle update rails
otherwise do this:
open -e Gemfile
: to change Rails version to 4.2.11.1 then run
gem install rails
: If all is not well, check your gemset with:
rvm gemset list
: decipher the terminal response.
If you see an error such as:
Ignoring executable-hooks-1.3.2 because its extensions are not built.
Try: gem pristine executable-hooks --version x.x.x
DO NOT DO the Try suggestion.
It means you are in the default or global gemset or you have a brand new gemset.
Verify your app's gemset with:
rvm gemset list
Changing gemset will work if you are in wrong one.
You want to be here: Rails4.2_your_app_name
You get there by running this, anytime:
rvm gemset use Rails4.2_app_name
Now run:
gem install rails
Now run this:
bundle update rails
Now run:
bundle_install
Now, do we have any outdated gems ?
This is a safe command, changing nothing:
bundle outdated
Next command is not a safe one, possibly updating many gems,
changing many things:
See A VALID NOTE above, and note here below before running bundle update
Run bundle outdated
before you blindly run the following update command.
You can see how many gems will be updated if all are done with one command.
You can update gems one by one with bundle update gem_name
Recommend you do a git commit
command before you run this
updates-all-gems-command, if you have many gems outdated.
bundle update
ruby -v
rails -v
gem list
: shows you all gems in your new gemset
Choose your correct gemset for your app, if you have more than one.
Let us presume this is your first gemset ..
We will create a good name for it : Rails4.2_app_name
Yes, change the app_name to your app's name for easy reference.
When you upgrade to Rails5.1 simply create a new gemset, and you
can revert to the Rails5.1 gemset should the need arise.
Your app is now ready to go.
At any time you can do the steps above to keep your app humming.
As needed to be current, make appropriate changes here:
open -e .ruby-gemset
open -e .ruby-version
bundle install
Fire it up with:
rails s
If you ever lose track of where you are, commands wise, just type into your Terminal:
history
history -10
pwd
print working directory to see where you are
Your app is now updated, Ruby, Rails and gems wise.
Welcome to the your working versions of Ruby on Rails.
Your Rails app's health brought to you by
This list draws heavily upon my learnings with RailsApps Tutorials.
If you are looking for a Ruby on Rails Tutorial, go RailsApps,
where you can truly begin at the beginning and learn your way to
deploy with confidence. We did.
Did you know FIXNUM and BIGNUM are aliases for INTEGER in the upgrade to Ruby 2.4.1.
See:
Behavior Changes in Ruby 2.4
Address of This Rails Applications Health Codes Gist is :
https://gist.github.com/kathyonu/c9ef8190e50422bc0edc