質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

0回答

1867閲覧

rails new で cannot load such file -- bootsnap/setup (LoadError) が発生する原因がわかりません

27kan

総合スコア0

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/02/13 09:47

編集2021/03/07 09:43

前提・実現したいこと

こんにちは。
現在パーフェクト Rails を読みながらサンプルのコードを実行してアプリケーションを作っています。

最初の rails new をするところで
bundle exec rails new hello_rails を実行したところ、以下のエラーが発生しました。

$ ~/workspace/perfect-rails/part-1 be rails new hello_rails [ 21-02-13 18:17 ] create create README.md create Rakefile create .ruby-version create config.ru create .gitignore create Gemfile run git init from "." Initialized empty Git repository in /Users/27kan/workspace/perfect-rails/part-1/hello_rails/.git/ create package.json create app create app/assets/config/manifest.js create app/assets/stylesheets/application.css ・・・中略・・・ Using tilt 2.0.10 Using sassc-rails 2.1.2 Using sass-rails 6.0.0 Using selenium-webdriver 3.142.7 Using spring 2.1.1 Using spring-watcher-listen 2.0.1 Using sqlite3 1.4.2 Using turbolinks-source 5.2.0 Using turbolinks 5.2.1 Using web-console 4.1.0 Using webdrivers 4.5.0 Using webpacker 4.3.0 Bundle complete! 17 Gemfile dependencies, 75 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed. run bundle binstubs bundler 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`. run bundle exec spring binstub --all * bin/rake: Spring inserted * bin/rails: Spring inserted rails webpacker:install Traceback (most recent call last): 3: from bin/rails:8:in `<main>' 2: from bin/rails:8:in `require_relative' 1: from /Users/27kan/workspace/perfect-rails/part-1/hello_rails/config/boot.rb:4:in `<top (required)>' /Users/27kan/workspace/perfect-rails/part-1/hello_rails/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError) $ ~/workspace/perfect-rails/part-1

このエラーを回避するには config.boot.rb

rb

1require 'bootsnap/setup'

をコメントアウトすればよいのはわかるのですが、
そもそもどうしてこのようなエラーが発生するのかわからずモヤモヤしており、解決方法を教えていただきたいです。

ruby のバージョンは 2.5.1,
rails のバージョンは 6.0.3 です。

試したこと

Gemfile には bootsnap gem の記載があります。
また bootsnap gem がインストールされていることは確認しました。

$ ~/workspace/perfect-rails/part-1/hello_rails [master] ⚡ bundle list | grep bootsnap [ 21-02-13 18:29 ] 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`. * bootsnap (1.7.2) $ ~/workspace/perfect-rails/part-1/hello_rails [master]

また、 /Users/27kan/.anyenv/envs/rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.7.2/ の中に lib/bootsnap/setup.rb があることを確認したので、どうして

cannot load such file -- bootsnap/setup (LoadError)

が発生するのかわかりません…

回答どうぞよろしくおねがいします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

technocore

2021/02/13 16:39 編集

>ruby のバージョンは 2.5.1 わざわざ3年ほど前の古いrubyをなぜ使っているのですか? WARNING: ruby-2.5.1 is nearing its end of life. It only receives critical security updates, no bug fixes.
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問