Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Bootsnap fails to load

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?

like image 414
Jerome Avatar asked Aug 03 '19 06:08

Jerome


2 Answers

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

like image 149
Promise Preston Avatar answered Oct 13 '22 00:10

Promise Preston


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.

like image 26
matiss Avatar answered Oct 13 '22 01:10

matiss