What to do if the app is not created with the latest Rails version installed when rails new

I'm addicted to the latest version of Rails installed when I ran rails new, so I'll post it.

Introduction

If you rails new without specifying a version, the app will be created with the latest version of Rails you have installed. However, what I encountered was the phenomenon that when rails new was done, the app was created with an older version instead of the latest version. Moreover, that version was not displayed even with the gem list command. ..

Cause of a problem

If I write the cause first, there was a problem with the setting of environment variables.

/ usr / local / bin is defined before /Users/user_name/.rbenv/shims, and $ PATH has priority over writing, so / usr / local / bin It was because / rails was used. In other words, it was referring to Rails installed on the mac, not the Rails version managed by rbenv.

$ echo $PATH
/usr/local/bin:(Omission)/Users/user_name/.rbenv/shims:/Users/user_name/.rbenv/bin:
(The following is omitted)

Flow from problem occurrence to resolution

What happened

When I tried to create a new app and ran the rails new command without a version specified, it was created with an older version (5.2.3) instead of the latest installed version (6.0.3).

Gemfile


source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.3.7'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.3'
(Omitted below)

When I checked the Rails version, it was 5.2.3, but the version I checked with the gem list command did not include 5.2.3.


$ rails -v
Rails 5.2.3

When I checked the Rails execution location with which rails, it was / usr / local / bin / rails. The reason for this is that, as mentioned above, the environment variable defined / usr / local / bin / rails before the rbenv path.

$ which rails
/usr/local/bin/rails

When I opened the lid, it was a simple problem, but once I uninstalled all the gems, it was useless, so I hope it helps those who have trouble with the same problem.

Other possible causes

Railties also seem to be suspicious when rails -v shows a version of Rails that shouldn't exist. Check railties when the Rails version is wrong-a pretty awesome blog

Recommended Posts

What to do if the app is not created with the latest Rails version installed when rails new
What to do if you installed Ruby with rbenv but the version does not change
[Swift] What to do if the app icon is set but not reflected
[Ubuntu 20.04] What to do if the external monitor is not recognized
[Rails] What to do if data is not registered in DB
What to do if Cloud9 is full in the Rails tutorial
[Rails] What to do when the view collapses when a message is displayed with the errors method
[IOS] What to do when the image is filled with one color
What to do if the background image is not applied after deployment
What to do if the prefix c is not bound in JSP
[Note] What to do if bundle install in Chapter 3 of the rails tutorial is not possible
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do when rails db: seed does not reflect in the database
repository The specified gem is bundle installed but not updated to the latest version
What to do when is invalid because it does not start with a'-'
What to do if the Rails server can't start
[Rails] What to do when the Refile image is not displayed when writing the processing at the time of Routing Error
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if the update does not take effect after deploying Rails AWS
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do if the JSONHint annotation does not work with lombok and JSONIC
What to do if the breakpoint is shaded and does not stop during debugging
What to do when you launch an application with rails
What to do if FacesMessage is set but not displayed
What to do if you can't use the rails command
What to do if you hit the wall of Too many symbol files when uploading with App Store Connect
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
[Android] How to check if the Google Play developer service is installed when the app is launched
[Rails] What to do if you can't get an error message with the errors method
What to do when Rails on Docker does not reflect controller changes in the browser
What to do if validation doesn't work with the update action
What to do when the changes in the Servlet are not reflected
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if the Eclipse Maven dependency Jar is wrong
[Rails] What to do when rails s does not respond or does not stop
[Rails] What to do if you can't get parameters with form_with
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
What to do if deployment fails on Heroku (Ruby app not detected)
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do if you get Application with name appName is already registered. When you try to start GlassFish
What to do if you should have installed Rails but an error occurs with rails -v (for beginners)
What to do if zip dies if there is a pom when making an executable jar with gradle
[Rails / Docker] What to do if access is denied by the browser (localhost: 3000) after adding a gem
Downgrade an existing app created with rails 5.2.4 to 5.1.6
What to do if you can't activate the select box created by bootstrap-select
What to do if the changes are not reflected in the jar manifest file
[Grails] Error occurred running What to do when the Grails CLI does not start
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
What to do if the rails server doesn't run out on AWS cloud9
What to do if ffi installation fails when launching an application in Rails
I specified the version and rails new, but for some reason the latest version is included ~
[React.useRef] What to do when the latest state cannot be referenced in the event listener
What to do when The SSL certificate has expired
What to do if ClassNotFoundException occurs when starting Tomcat
What to do if rails server can't be stopped
What to do when rails creates a 〇〇 2.rb file
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
What to do when Address already in use is displayed after executing rails s
What to do when routing settings do not work after building Docker environment with Laravel
Library not loaded when trying to upgrade the version of ruby and rails s