前提・実現したいこと
初学者で、質問等に足りていない部分もあるかもしれませんが、何卒よろしくお願いします。
rails sでサーバーを起動しさせたいです。
旧mac book airから新しくmacbook Pro M1 13inに変えたのですが、自分が学習用で作っていたプログラムをそのまま移植して、学習したいのですが、rails sでサーバーを起動させようとすると以下のようなエラーメッセージが出るのですが、どのように対処したらよろしいのでしょうか?
(追記)
ruby -vの結果ですバージョンは2.5.8になっていました。 -FKMさん
gemfileを追加しました。rubyは2.5.8になっているように見えます。-goufさん
ruby-versionは自分が動かしているプロジェクト内のものでよろしいのでしょうか? - matuandさん
gemfile
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.5.8' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 5.2.3' 8# Use sqlite3 as the database for Active Record 9gem 'sqlite3' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5.0' 14# Use Uglifier as compressor for JavaScript assets 15gem 'uglifier', '>= 1.3.0' 16# See https://github.com/rails/execjs#readme for more supported runtimes 17# gem 'mini_racer', platforms: :ruby 18 19# Use CoffeeScript for .coffee assets and views 20gem 'coffee-rails', '~> 4.2' 21# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 22gem 'turbolinks', '~> 5' 23# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 24gem 'jbuilder', '~> 2.5' 25# Use Redis adapter to run Action Cable in production 26# gem 'redis', '~> 4.0' 27# Use ActiveModel has_secure_password 28# gem 'bcrypt', '~> 3.1.7' 29 30# Use ActiveStorage variant 31# gem 'mini_magick', '~> 4.8' 32 33# Use Capistrano for deployment 34# gem 'capistrano-rails', group: :development 35 36# Reduces boot times through caching; required in config/boot.rb 37gem 'bootsnap', '>= 1.1.0', require: false 38 39group :development, :test do 40 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 41 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 42end 43 44group :development do 45 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 46 gem 'web-console', '>= 3.3.0' 47 gem 'listen', '>= 3.0.5', '< 3.2' 48 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 49 gem 'spring' 50 gem 'spring-watcher-listen', '~> 2.0.0' 51end 52 53group :test do 54 # Adds support for Capybara system testing and selenium driver 55 gem 'capybara', '>= 2.15' 56 gem 'selenium-webdriver' 57 # Easy installation and use of chromedriver to run system tests with Chrome 58 gem 'chromedriver-helper' 59end 60 61# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 62gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 63
発生している問題・エラーメッセージ
$ yuharadaiki@yuharadaikinoMacBook-Pro sample % rbenv versions $ system $ * 2.5.8 (set by /Users/yuharadaiki/Documents/ruby_lesson/sample/.ruby-version) 2.6.3 $ yuharadaiki@yuharadaikinoMacBook-Pro sample % rails s $ Your Ruby version is 2.6.3, but your Gemfile specified 2.5.8 yuharadaiki@yuharadaikinoMacBook-Pro sample % ruby -v ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-darwin20] Traceback (most recent call last): 52: from bin/rails:3:in `<main>' 51: from bin/rails:3:in `load' 50: from /Users/yuharadaiki/Documents/ruby_lesson/sample/bin/spring:15:in `< top (required)>' 49: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby /2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 48: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby /2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 47: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11 :in `<top (required)>' 46: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/lib/spring/binstub.rb:11 :in `load' 45: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/bin/spring:49:in `<top ( required)>' 44: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/lib/spring/client.rb:30: in `run' 43: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/lib/spring/client/comman d.rb:7:in `call' 42: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails. rb:28:in `call' 41: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.1/lib/spring/client/rails. rb:28:in `load' 40: from /Users/yuharadaiki/Documents/ruby_lesson/sample/bin/rails:9:in `<to p (required)>' 39: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:31:in `require' Gemfile4:1 LFUTF-8Ruby no branchNot on branchGitHubGit (93)1 update 38: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' 37: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/loaded_features_index.rb:92:in `register' 36: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' 35: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `require' 34: from /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.5/lib/rails/commands.r b:18:in `<main>' 33: from /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.5/lib/rails/command.rb :46:in `invoke' 32: from /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.5/lib/rails/command/ba se.rb:69:in `perform' 31: from /Library/Ruby/Gems/2.6.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispat ch' 30: from /Library/Ruby/Gems/2.6.0/gems/thor-1.1.0/lib/thor/invocation.rb:127 :in `invoke_command' 29: from /Library/Ruby/Gems/2.6.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run' 28: from /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.5/lib/rails/commands/s erver/server_command.rb:142:in `perform' 27: from /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.5/lib/rails/commands/s erver/server_command.rb:142:in `tap' 26: from /Library/Ruby/Gems/2.6.0/gems/railties-5.2.4.5/lib/rails/commands/s erver/server_command.rb:145:in `block in perform' 25: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:31:in `require' 24: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' 23: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/loaded_features_index.rb:92:in `register' 22: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' 21: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `require' 20: from /Users/yuharadaiki/Documents/ruby_lesson/sample/config/application. rb:7:in `<main>' 19: from /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.15/lib/bundler.rb:173:in `require' 18: from /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.15/lib/bundler/runtime.rb :50:in `require' 17: from /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.15/lib/bundler/runtime.rb :50:in `each' 16: from /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.15/lib/bundler/runtime.rb :61:in `block in require' 15: from /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.15/lib/bundler/runtime.rb :61:in `each' 14: from /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.15/lib/bundler/runtime.rb :66:in `block (2 levels) in require' 13: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:31:in `require' 12: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' 11: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/loaded_features_index.rb:92:in `register' 10: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' 9: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `require' 8: from /Library/Ruby/Gems/2.6.0/gems/uglifier-4.2.0/lib/uglifier.rb:5:in ` <main>' 7: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:31:in `require' 6: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' 5: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/loaded_features_index.rb:92:in `register' 4: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' 3: from /Library/Ruby/Gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path _cache/core_ext/kernel_require.rb:23:in `require' 2: from /Library/Ruby/Gems/2.6.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<mai n>' 1: from /Library/Ruby/Gems/2.6.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<mod ule:ExecJS>' /Library/Ruby/Gems/2.6.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect' : Could not find a JavaScript runtime. See https://github.com/rails/execjs for a lis t of available runtimes. (ExecJS::RuntimeUnavailable)
### 試したこと ruby 2.5.8 を rbenv経由で再インストールしました。 gemfileのバージョン指定を外した結果、bundleからgemをインストールするように促されましたので、 'bundle install'を実行したのちに、再度rails sを実行すると上記エラーのうちの最後のものが表示されました。 bundle exec rails s 及び rbenv exec rails s を実行したのですが、コマンドがないとエラーが出ました。 ### 補足情報(FW/ツールのバージョンなど) ここにより詳細な情報を記載してください。
回答2件
あなたの回答
tips
プレビュー