40
How to upgrade your Rails app to Ruby 3.1 with rbenv
Ruby 3.1 release documentation
To include Ruby 3.1 as one of the available install options, first upgrade ruby-build:
brew update && brew upgrade ruby-build
See all available versions with rbenv install --list
.
Ruby 3.1.0
should return in the result.
rbenv install 3.1.0
rbenv local 3.1.0
You can verify that the .ruby-version
file in the root of your folder now lists version 3.1.0.
# old
ruby "3.0.3"
# new
ruby "3.1.0"
bundle install
You might run into the error cannot load such file -- net/smtp (LoadError). net-smtp
has been removed from the default gems in ruby 3.1. As Action Mailbox depends on net/smtp temporarily add to your gemfile until the mail
gem includes it as a dependancy.
gem "net-smtp", require: false
The debug gem is the new preferred debugger. Alternative gems like pry
are no longer necessary. Rails 7 includes the debug gem by default.
Gemfile:
group :development, :test do
# old
gem 'pry'
# new
gem "debug", ">= 1.0.0"
end
Learn more in this video
- Error highlighting examples
- IRB auto-completion
- Typeprof examples / vs code extension / video
- Short Syntax Hash Values examples
40