I'm addicted to the latest version of Rails installed when I ran rails new
, so I'll post it.
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. ..
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)
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.
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