Rails: Bootsnap fails to load
Asked Answered
P

3

9

When launching a rails 5 application today the following error is being hit:

1: from /home/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/compile_cache/iseq.rb:37:in `load_iseq'
/home/deploy/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/compile_cache/iseq.rb:37:in `fetch': 
Operation not permitted - bs_fetch:atomic_write_cache_file:chmod (Errno::EPERM)

Other questions here seem to point to a solution where the gemfile call has require: false but that is already specified

gem 'bootsnap', '>= 1.1.0', require: false

The only way the application server can start (in development mode for the time being) is by commenting out from boot.rb the following line:

# require 'bootsnap/setup' # Speed up boot time by caching expensive operations.

Between previous re-boot (yesterday) and present moment, neither the boot.rb nor Gemfile was modified. Toggling this line on and off proves the issue is with bootsnap.

What is wrong? What is going on?

Pimply answered 3/8, 2019 at 6:29 Comment(3)
Same here. Did you manage to get some solution?Shanteshantee
Unfortunately not. If you find something, please post here.Pimply
I believe Promise Preston's answer about tmp directory permissions is fundamentally correct, but the exact solution may vary according to circumstances.Tedmann
C
17

I experienced this issue when working on a Rails application that has been working fine for sometime.

The problem is that Bootsnap gem tmp directory in your application directory is not writable to the current user, that is, the current user does not have permission to write to the Bootsnap gem tmp directory in your application directory.

Here's how I solved it:

Simply delete the tmp directory in your application directory with superuser rights:

sudo rm -rf tmp

Do not recreate the tmp directory again, it's a waste of effort

Simply start your application and the tmp directory will be created automatically again:

rails s

That's all.

I hope this helps

Carlyn answered 16/4, 2020 at 14:21 Comment(1)
Thanks bro...perfect!!Tamaratamarack
S
1

I'm using WSL on Win10, few days ago some big update came and nothing worked as usual. As I understand WSL changed some settings for folder permissions, or something.

As my projects are located under C:\sites it appears Bootsnap needs to have full rights for C:\sites\mywebsite\tmp\cache\bootsnap-compile-cache

Reply in this GitHub issue suggests the folder has to be writable. So basically I had to grant full access for my Win10 user to my C:\sites and subfolders. In order to to that I followed this tutorial If for some reason this doesn't work right away, try to remove "read-only" for your "sites" folder, e.g., cheeck this suggestion

The buttom line is - you have to have full rights for that cache folder, so Bootsnap can write in there its folders and files.

I hope this helps.

Shanteshantee answered 17/8, 2019 at 8:26 Comment(0)
T
0

I ran into this with a Docker container in which the Rails app root directory was a volume mounted from the host. Deleting the tmp directory (per Promise Preston's answer) didn't solve the problem, because then Rails couldn't create it.

Probably this answer (or one like it) would lead to the correct Docker-permissions solution there, but I got fed up and just copied the app directory into the container instead of mounting it.

Tedmann answered 20/2, 2021 at 4:34 Comment(1)
I had the same problem inside a Docker container. A simple bundle update bootsnap fixed the problem for me.Pyrethrin

© 2022 - 2024 — McMap. All rights reserved.