(New to Rails) rails server error: cannot load such file -- bootsnap/setup (LoadError)
Asked Answered
D

2

20

I have installed my JS runtime as Node, and I have bundle update-ed and bundle install-ed, but I still get this error:

/Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/config/boot.rb:4:in `<top (required)>'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/rails:8:in `require_relative'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/rails:8:in `<top (required)>'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
    from /Users/macbook/.rvm/gems/ruby-2.3.4/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/spring:15:in `require'
    from /Users/macbook/Documents/Studies/Coding/the_back_end/the_odin_project/odin_on_rails/hello_app/bin/spring:15:in `<top (required)>'
    from bin/rails:3:in `load'
    from bin/rails:3:in `<main>'

Here's what's in my Gemfile ,

source 'https://rubygems.org'

gem 'rails',        '5.1.4'
gem 'puma',         '3.9.1'
gem 'sass-rails',   '5.0.6'
gem 'uglifier',     '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks',   '5.0.1'
gem 'jbuilder',     '2.7.0'


group :development, :test do
  gem 'sqlite3', '1.3.13'
  gem 'byebug',  '9.0.6', platform: :mri
end

group :development do
  gem 'web-console',           '3.5.1'
  gem 'listen',                '3.1.5'
  gem 'spring',                '2.0.2'
  gem 'spring-watcher-listen', '2.0.1'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

I feel a little lost on that one, and I can't find any helpful answer anywhere.

Thanks a lot in advance!

Durance answered 24/7, 2018 at 8:9 Comment(0)
T
30

You have an issue with the gem bootsnap which main job is to accelerate rails startup time.

So, you should either :

  • In case you want bootsnap, add gem 'bootsnap' to your gemfile to install it.
  • In case you don't want bootsnap, remove the line require 'bootsnap/setup' in config/boot.rb

More info about bootsnap : https://github.com/Shopify/bootsnap#how-does-this-work

Taxis answered 24/7, 2018 at 8:19 Comment(2)
I just did that, but then this other error appeared, /Users/macbook/.rvm/gems/ruby-2.3.4/gems/railties-5.1.4/lib/rails/application/configuration.rb:81:in `load_defaults': Unknown version "5.2" (RuntimeError)Durance
I think you messed up with your Gemfile, because all your apps files seems to be from 5.2 version of rails while your Gemfile have gem 'rails', '5.1.4', you can try replacing it by gem 'rails', '~> 5.2' and launching an bundle installTaxis
A
0

Clear the cache on tmp.

tmp > bootsnap -> delete all the files.

enter image description here

Acrimony answered 2/9, 2023 at 21:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.