bootsnap: `require': cannot load such file -- bootsnap/setup (LoadError)

I just followed the setup process mentioned in the README and got this error.

confit/boot.rb

ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup'

Error stack

home/bhanu/workspace/truckola/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
	from /home/bhanu/workspace/truckola/config/boot.rb:4:in `<top (required)>'
	from /home/bhanu/workspace/truckola/bin/rails:8:in `require_relative'
	from /home/bhanu/workspace/truckola/bin/rails:8:in `<top (required)>'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
	from /home/bhanu/.rbenv/versions/2.3.1/gemsets/truckola/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
	from /home/bhanu/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /home/bhanu/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /home/bhanu/workspace/truckola/bin/spring:13:in `<top (required)>'
	from bin/rails:3:in `load'
	from bin/rails:3:in `<main>'

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 15 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I had a string of various LoadErrors and clearing the bootsnap cache finally cleared the load errors for me. Here’s how I did that:

  • go to the project home, then cd into tmp/cache
  • delete bootsnap-load-path-cache and bootsnap-compile-cache

h/t #53

Not sure if deleting both the directory and the binary file there are necessary, perhaps you only have to clear one? Regardless, clearing it out got rid of load errors.

@nicolasmlv you are using bootsnap (0.2.12) which did not include this file. We are now on bootsnap 1.1.2 (After jumping from 0.3.x which introduced bootsnap/setup).

Please run bundle update bootsnap 😃

Sorry I found the solution, I installed just the wrong rails version … Thank you all

ok it works, I think you can close the issue

rm -rf .bundle; bundle install solved for me

It happened every I call rails on my project folder. Even right after I created fresh new project. rm -rf .bundle; bundle install did not work on mine. Any ideas?

$ rails --version
/Users/mac/Devs/Rails/test/rails-test-api/config/boot.rb:4:in `require': cannot load such file -- bootsnap/setup (LoadError)
	from /Users/mac/Devs/Rails/test/rails-test-api/config/boot.rb:4:in `<top (required)>'
	from bin/rails:3:in `require_relative'
	from bin/rails:3:in `<main>'

ruby --version ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]

rails --version (this also give me those error, so I move to non rails project folder and excecute this) Rails 7.0.4

bootsnap bootsnap-1.13.0

In our case, we didn’t have wrong rails version installed and this still happened. Even removing

  • rvm ruby installation and re-installing it didn’t fix it
  • bundle install other bundle commands. Nothing helps it.
  • 'gem pristine --all` doesn’t work as well.

because gems are okay and everything else is installed correctly.

Only way to get rid of random LoadErrors is deleting the files below IN THE APP. -app/tmp/cache/bootsnap-load-path-cache -app/tmp/cache/bootsnap-compile-cache

This still happens with the newest bootsnap 1.4.6. For some reason, it doesn’t clean up the load path cache after new gem installations or updates. I’m not sure the logic behind it.

@riyanpratamap I got almost the same issue with “require_relative”. Nothing helped, so I decided to update ruby-build

 brew upgrade ruby-build

and rebuild the Ruby by rbenv.

rbenv install ruby 2.7.5 # do not forget to delete it before

and it helped.

I think this issue is connected to the Mac OS update (Ventura in my case)

  • bootsnap-load-path-cache

how do i delete the files