Can start a new Rails app with Ruby 2.5.0 but not in 2.5.3

My development environment has rbenv with Ruby 2.5.0 and 2.5.3. I can start a new Rails app in Ruby 2.5.0 but not in Ruby 2.5.3. Here’s the script I’m using for creating a quick and dirty Rails app:


#!/bin/bash

# This script creates a basic Rails app that uses an SQLite database.
# PURPOSE: Provide confirmation that Ruby on Rails is properly set up.

# This is the same test app as the one at [http://elinux.org/RPi_Ruby_on_Rails](http://elinux.org/RPi_Ruby_on_Rails) .
cd /home/winner/shared && rails new school_sq --skip-spring
cd /home/winner/shared/school_sq && rails g scaffold Pupil name:string form:string
cd /home/winner/shared/school_sq && rake db:migrate

echo '**********************'
echo 'OPEN YOUR WEB BROWSER.'
echo 'GO TO THE FOLLOWING URL:'
echo '[http://localhost:3000/pupils](http://localhost:3000/pupils)'

echo '***************'
echo 'IMPORTANT NOTE:'
echo 'The port number listed above assumes a zero offset for the port number.'
echo 'If you are using a non-zero offset in Docker,'
echo 'you must adjust the above port number accordingly.'
echo '**************************************************'

echo ''
cat /home/winner/shared/ports.txt
echo ''

echo '*************************************************************************'
echo "You can use access the database in this app's db/development.sqlite3 file"
echo 'by using SQLite database browser.'
echo '*********************************'
cd /home/winner/shared/school_sq && rails s -b 0.0.0.0 -p 3000

When I run this script in Ruby 2.5.0, I have no problems. Everything works as expected.

But when I run this script in Ruby 2.5.3 (rbenv global 2.5.3), I keep getting error messages:

When I first run the script, I get the message “Your Ruby version is 2.5.3, but your Gemfile specified 2.5.0” during the “bundle install” part. It turns out that the Gemfile specifies Ruby 2.5.0. (WHY does Rails app generator insist on Ruby 2.5.0 instead of 2.5.3?) 2. When I correct the Gemfile, I get the message “Your Ruby version is 2.5.0, but your Gemfile specified 2.5.3” when I run “rails db:migrate”.

When I enter “bin/rails db:migrate RAILS_ENV=development”, the error message doesn’t appear. However, I get the message “Your Ruby version is 2.5.0, but your Gemfile specified 2.5.3” when I enter “rails s -b 0.0.0.0 -p 3000”.

I have some apps in Ruby 2.5.0. I want to upgrade them to 2.5.3, but I get a similar conundrum. So I’m sticking with Ruby 2.5.0, because stagnation is better than breakage.

Why is Ruby 2.5.3 such a problem? Should I just wait for 2.6.0 to be released before upgrading?

2.5.3 works perfectly fine for me. have you tried rbenv rehash after switching ruby versions?

Did you run bundle install after changing the ruby version in Gemfile?

Colin