I specified the version and rails new, but for some reason the latest version is included ~

Introduction

The purpose of this article is to introduce the procedure for rails new Rails 6.0.3.1 app in the local environment Rails 6.0.3.3 and the error handling that occurred at that time.

environment

Rails 6.0.3.3

procedure

1 Check the installed rails version

% rails -v  
Rails 6.0.3.3

2 Check the list of available versions

% gem list rails
** LOCAL GEMS ***

rails (6.0.3.4, 6.0.3.3, 6.0.3.2, 5.2.4.3)

3 Install rails 6.0.3.1

gem i -v 6.0.3.1 rails

4 Check the version again

% gem list rails                                                                                                                                                                               

*** LOCAL GEMS ***

rails (6.0.3.4, 6.0.3.3, 6.0.3.2, 6.0.3.1, 5.2.4.3)

5 "rails new" without loading Gemfile

rails _6.0.3.1_ new SampleApp -d mysql --skip-bundle

Explanation

---d mysql specifies DB as mysql.

--Enter the version name (number) you want to specify in place of _6.0.3.1_. --new Sample App is the app name. ---- skip-bundle specifies that Gemfile should not be read.

6 Edit Gemfile

At the moment, the local rails version (6.0.3.3 in this case) is specified, so edit the Gemfile and change it to the version you want to specify (6.0.3.1 in this case).

Before change) gem'rails', '~> 6.0.3.3'
After change) gem'rails', '= 6.0.3.1'

Explanation

--~> 6.0.3.3 means that rails 6.0.x.x (6.0 series) can be used, so the latest 6.0.3.3. will be installed in this state.

7 bundle install

% bundle install

Then the following error occurs

The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "activesupport":
  In snapshot (Gemfile.lock):
    activesupport (= 6.0.3.4)

  In Gemfile:
    web-console (>= 3.3.0) was resolved to 4.0.4, which depends on
      actionview (>= 6.0.0) was resolved to 6.0.3.4, which depends on
        activesupport (= 6.0.3.4)

    rails (= 6.0.3.1) was resolved to 6.0.3.1, which depends on
      activesupport (= 6.0.3.1)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Simply put, I get an error saying "If you want to specify rails 6.0.3.1, you can't use other gems unless you match the version! ".

So, as instructed by the error statement, change the version of other gems with bundle update.

8 bundle update

% bundle update

Check if the specified version of the app can be created

% rails -v
Rails 6.0.3.1

This is the end!

reference

[Rails error] What to do if a higher version is included even if you specify the version with rails new https://techtechmedia.com/rails-new-version-error/

Recommended Posts

I specified the version and rails new, but for some reason the latest version is included ~
repository The specified gem is bundle installed but not updated to the latest version
Enum misconfiguration. For some reason, I can't get data from the column specified by Enum ...
The strong parameter is true, but for some reason it cannot be saved in the table.
What to do if the app is not created with the latest Rails version installed when rails new
In DynamoDB Enhanced Client, I access the index table for some reason
[Rails] I studied the difference between new method, save method, build method and create method.
[Ruby] Your Ruby version is 2.6.3, but your Gemfile specified 2.5.8
Your Ruby version is 2.4.6, but your Gemfile specified 2.6.4
[Rails] I tried to raise the Rails version from 5.0 to 5.2
I summarized the naming conventions for each Rails
[Rails] I learned about the difference between resources and resources
[CentOS] Download and build the specified version of Git
[Rails] What is the difference between redirect and render?
What should I use for the testing framework [Rails]
When the vagrant command doesn't work for some reason
[Rails] I investigated the difference between redirect_to and render.