質問内容・実現したいこと
質問内容
herokuのデプロイの際にrubyのバージョンアップが必要になり
ruby 2.5.1 から ruby 3.1.0 に変更しrails s
するもerrorになります。
実現したいこと
ローカルのrailsサーバーにつながりたい。
教えていただきたいこと
- errorの解消方法またはヒント
- errorの読み解き方
- ここをこうした方がいいよなどご指摘をいただきたいです。
よろしくお願いします。
現状発生している問題・エラーメッセージ
$ rails s /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- net/smtp (LoadError) from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:93:in `register' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:324:in `block in require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:291:in `load_dependency' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:324:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/mail-2.7.1/lib/mail.rb:9:in `<module:Mail>' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/mail-2.7.1/lib/mail.rb:3:in `<main>' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:105:in `register' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:324:in `block in require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:291:in `load_dependency' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:324:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/actionmailbox-6.0.4.4/lib/action_mailbox/mail_ext.rb:3:in `<main>' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:105:in `register' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.9.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.4.4/lib/active_support/dependencies.rb:324:in `block in require' from /Users/mark_naito/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-
行ったこと
bash
1#1 インストールできるrubyのバージョンを確認 2rbenv install --list 3 42.6.9 52.7.5 63.0.3 73.1.0 8jruby-9.3.2.0 9mruby-3.0.0 10rbx-5.0 11truffleruby-21.3.0 12truffleruby+graalvm-21.3.0 13 14Only latest stable releases for each Ruby implementation are shown. 15Use 'rbenv install --list-all / -L' to show all local versions. 16 17#2 リスト確認 18rbenv versions 19 system 20* 2.5.1 (set by /Users/mark_naito/.rbenv/version) 21 2.6.3 22 2.6.4 23 2.6.5 24 2.6.6 25 26#2 最新のrubyをインストール 27rbenv install 3.1.0 28Downloading openssl-1.1.1l.tar.gz... 29-> https://dqw8nmjcqpjn7.cloudfront.net/0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 30Installing openssl-1.1.1l... 31Installed openssl-1.1.1l to /Users/mark_naito/.rbenv/versions/3.1.0 32 33Downloading ruby-3.1.0.tar.gz... 34-> https://cache.ruby-lang.org/pub/ruby/3.1/ruby-3.1.0.tar.gz 35Installing ruby-3.1.0... 36ruby-build: using readline from homebrew 37Installed ruby-3.1.0 to /Users/mark_naito/.rbenv/versions/3.1.0 38 39#2 再度確認 40rbenv versions 41 42 system 43* 2.5.1 (set by /Users/mark_naito/.rbenv/version) 44 2.6.3 45 2.6.4 46 2.6.5 47 2.6.6 48 3.1.0 49 50#4 ruby 3.1.0を全体に採用 51mark_naito@MacBook-Pro ~ % rbenv global 3.1.0 52 53#5 バージョンを切り替えとで変更を反映 54mark_naito@MacBook-Pro ~ % rbenv rehash 55 56#6 しっかり変更されているか確認 57mark_naito@MacBook-Pro ~ % ruby -v 58ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin21] 59 60#7 gemfileと.ruby-versionsファイルのrubyバージョンを3.1.0に変更 61 62#8 ホームディレクトリで実装していたので 63mark_naito@MacBook-Pro ~ % bundle install 64Could not locate Gemfile 65 66#9 開発中のアプリに移動 67mark_naito@MacBook-Pro ~ % cd my_application 68mark_naito@MacBook-Pro my_application % cd lets_hang_out 69 70#10 ファイルと実際のバージョンが一致しない 71mark_naito@MacBook-Pro lets_hang_out % bundle install 72Your Ruby version is 2.5.1, but your Gemfile specified 3.1.0 73 74#11 開発中のアプリに移動するもrubyのバージョンはそのまま 75mark_naito@MacBook-Pro lets_hang_out % ruby -v 76ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin20] 77 78#12 確認 79mark_naito@MacBook-Pro lets_hang_out % rbenv versions 80 system 81* 2.5.1 (set by /Users/mark_naito/my_application/lets_hang_out/.ruby-version) 82 2.6.3 83 2.6.4 84 2.6.5 85 2.6.6 86 3.1.0 87 88#13 rubyのバージョンを切り替える 89mark_naito@MacBook-Pro lets_hang_out % rbenv global 3.1.0 90 91#14 インストールしたrubyを使用できるようにする 92mark_naito@MacBook-Pro lets_hang_out % rbenv rehash 93 94#15 rubyのバージョンが切り替わっているか確認するも切り替わっていない。。 95mark_naito@MacBook-Pro lets_hang_out % ruby -v 96ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin20] 97 98#16 localでrubyのバージョンを切り替える 99mark_naito@MacBook-Pro lets_hang_out % rbenv local 3.1.0 100 101#17 確認 102mark_naito@MacBook-Pro lets_hang_out % ruby -v 103ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin21] 104 105#18 ruby2.5.1で生成されたGemfile.lookを一旦削除 106mark_naito@MacBook-Pro lets_hang_out % rm gemfile.lock 107 108#19 Gemfile.lockをRubyバージョン3.0.1で再生成 109mark_naito@MacBook-Pro lets_hang_out % bundle install 110Fetching gem metadata from https://rubygems.org/......... 111 112#20 再生成されたGemfile.lockに記載されているRUBY VERSIONと一致しているのを確認し一致 113ruby -v 114ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-darwin21]
該当のソースコード
Gemfile
ruby
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '3.1.0' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main' 7gem 'rails', '~> 6.0.4' 8# Use postgresql as the database for Active Record 9gem 'pg', '>= 0.18', '< 2.0' 10# Use Puma as the app server 11gem 'puma', '~> 4.1' 12# Use SCSS for stylesheets 13gem 'sass-rails', '>= 6' 14# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 15gem 'webpacker', '~> 4.0' 16# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 17gem 'turbolinks', '~> 5' 18# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 19gem 'jbuilder', '~> 2.7' 20# Use Redis adapter to run Action Cable in production 21# gem 'redis', '~> 4.0' 22# Use Active Model has_secure_password 23# gem 'bcrypt', '~> 3.1.7' 24 25# Use Active Storage variant 26# gem 'image_processing', '~> 1.2' 27 28# Reduces boot times through caching; required in config/boot.rb 29gem 'bootsnap', '>= 1.4.2', require: false 30 31group :development, :test do 32 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 33 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 34 35 # test 36 gem 'factory_bot_rails' 37 gem 'rspec-rails' 38end 39 40group :development do 41 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 42 gem 'web-console', '>= 3.3.0' 43 gem 'listen', '~> 3.2' 44 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 45 gem 'spring' 46 gem 'spring-watcher-listen', '~> 2.0.0' 47end 48 49# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 50gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 51 52# Assets 53gem 'bootstrap-sass' 54gem 'font-awesome-rails' 55gem 'jquery-rails' 56 57# Code analyze 58gem 'rails_best_practices' 59gem 'rubocop' 60 61# Debugger 62gem 'better_errors' 63gem 'binding_of_caller'
Gemfiel.look
ruby
1RUBY VERSION 2 ruby 3.1.0p0
エラーから考えられる原因
error内容にファイルが読み込めないと記述されているので
gemfileが読み読み込めるようにする必要がある?
ruby
1require': cannot load such file
参考にしたURL
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。