Project ruby and rails version upgrade

reference

https://qiita.com/kanacan/items/c1499f6c13b1c41da982

Current status

Gemfile

ruby '2.6.3'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.4', '>= 5.2.4.3'

Latest survey

Check in the list, 2.7.1 is the latest?

-> % rbenv install --list
2.5.8
2.6.6
2.7.1
jruby-9.2.12.0
maglev-1.0.0
mruby-2.1.1
rbx-5.0
truffleruby-20.1.0
truffleruby+graalvm-20.1.0

Update rbenv?

-> % brew upgrade rbenv ruby-build
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 4 taps (heroku/brew, homebrew/core, homebrew/cask and homebrew/services).
==> New Formulae

It was the latest version 2.7.1 The procedure one step up might not have meant https://www.ruby-lang.org/ja/downloads/ Yeah, 2.7.1 is on. So N (-> No).

-> % rbenv install 2.7.1
rbenv: /Users/(username)/.rbenv/versions/2.7.1 already exists
continue with installation? (y/N) N

But the project is 2.6.3. .. ..

-> % rbenv versions
  system
  2.3.7
  2.3.8
  2.5.1
  2.5.3
* 2.6.3 (set by /Users/(username)/projects/import_agent_app/.ruby-version)
  2.6.5
  2.6.6
  2.7.1
-> % git checkout -b feature/version_up
Switched to a new branch 'feature/version_up'
-> % rbenv local 2.7.1 
[feature/version_up *]
-> % rbenv versions
  system
  2.3.7
  2.3.8
  2.5.1
  2.5.3
  2.6.3
  2.6.5
  2.6.6
* 2.7.1 (set by /Users/(username)/projects/import_agent_app/.ruby-version)

-> % bundle install
Traceback (most recent call last):
        2: from /Users/(username)/.rbenv/versions/2.7.1/bin/bundle:23:in `<main>'
        1: from /Users/(username)/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems.rb:294:in `activate_bin_path'
/Users/(username)/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems.rb:275:in `find_spec_for_exe': Could not find 'bundler' (1.17.2) required by your /Users/(username)/projects/import_agent_app/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.17.2`

With this, I hit either of the following.

bundle update --bundler
gem install bundler:1.17.2

This got in the way while I was doing various things.

-> % bundle install
/Users/(username)/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-1.17.2/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated
Your Ruby version is 2.7.1, but your Gemfile specified 2.6.3

There were many articles that seemed to be because the version I was researching and referring to was different, but in my case, Gemfile

ruby '2.7.1'

I just had to rewrite it to. bundle install now works.

Next is Rails version upgrade This is also a Gemfile

gem 'rails', '~> 6.0.3', '>= 6.0.3.3'

Then you can go if you do budle install.

-> % bundle install
/Users/(username)/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/bundler-1.17.2/lib/bundler/rubygems_integration.rb:200: warning: constant Gem::ConfigMap is deprecated
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 (= 5.2.4.3)

  In Gemfile:
    rails (~> 6.0.3, >= 6.0.3.3) was resolved to 6.0.3.3, which depends on
      activesupport (= 6.0.3.3)

    web-console (>= 3.3.0) was resolved to 3.7.0, which depends on
      railties (>= 5.0) was resolved to 5.2.4.3, which depends on
        activesupport (= 5.2.4.3)

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

I got scolded.

bundle update

do it

bundle install

Then I was able to go.

Recommended Posts

Project ruby and rails version upgrade
Rails version upgrade memorandum 5.0 → 5.1
[Rails] Rails version upgrade error memorandum
Library not loaded when trying to upgrade the version of ruby and rails s
[Easy] How to upgrade Ruby and bundler
Rails and FormData
Ruby and Gem
Ruby on Rails ~ Basics of MVC and Router ~
[Ruby] Classes and instances
Rails valid? And invalid?
Symbols and Destructive Ruby
Chapter 4 Rails Flavored Ruby
Docker the development environment of Ruby on Rails project
[Ruby] Big Decimal and DECIMAL
About rails version specification
[Ruby] Project Euler Question 8
Ruby on Rails basics
Ruby inheritance and delegation
[Rails version control] rails version downgrade
Ruby On Rails Association
CentOS 7 curl version upgrade
(Ruby on Rails6) How to create models and tables
Ruby, Rails finally installed
I changed the Ruby version and now I can't bundle install
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
[Ruby on Rails] Infinite scrolling using gem kaminari and jscroll
[Rails] Launch a new project
Ruby on rails learning record -2020.10.03
Rails engineer environment construction ruby2.7.1
Ruby version switching with rbenv
Rails environment construction Rails5.2.1 ruby2.5.1 Catalina
Ruby on rails learning record -2020.10.04
GraphQL Ruby and actual development
[Rails] N + 1 problems and countermeasures
Rails: Difference between resources and resources
[Ruby on Rails] Debug (binding.pry)
Ruby on rails learning record -2020.10.05
Ruby on rails learning record -2020.10.09
Ruby on Rails config configuration
[Rails] require method and permit method
Rails "render method" and "redirect method"
Ruby version does not switch
Rails Tutorial Records and Memorandum # 0
rails path and url methods
Ruby syntax errors and countermeasures
Ruby on Rails basic learning ①
[Ruby on Rails] about has_secure_password
Rails is difficult and painful!
Ruby on rails learning record-2020.10.07 ②
About Ruby hashes and symbols
Introducing Bootstrap and Font-Awesome (Rails)
Ruby C extension and volatile
Commentary on partial! --Ruby on Rails
[Rails Tutorial Chapter 4] Rails-flavored Ruby
Ruby on rails learning record-2020.10.07 ①
Cancel Ruby on Rails migration
[Rails] strftime this and that
Ruby on rails learning record -2020.10.06
About Ruby and object model
[Ruby] Singular methods and singular classes
About Ruby classes and instances