bootsnap: Errno::EACCES: Permission denied
When we added bootsnap to our application we started getting the following errors whenever we run anything:
"Errno::EACCES: Permission denied",
"/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.2/lib/bootsnap/compile_cache/iseq.rb:37:in `fetch'",
"/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.2/lib/bootsnap/compile_cache/iseq.rb:37:in `load_iseq'",
"/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'",
"/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'",
"/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `block in require'",
"/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:258:in `load_dependency'",
"/app/vendor/bundle/ruby/2.4.0/gems/activesupport-5.1.2/lib/active_support/dependencies.rb:292:in `require'",
"/app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.1.2/lib/active_record/railtie.rb:34:in `block (3 levels) in <class:Railtie>'",
"/app/vendor/bundle/ruby/2.4.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'",
Cache path is /app/tmp/cache/bootsnap-compile-cache, which writable for the processes running tasks.
Also, some files are created:
$ /app/tmp/cache/bootsnap-compile-cache$ ls
00 05 0a 0f 14 19 1e 23 28 2d 32 37 3c 41 46 4b 50 55 5a 5f 64 69 6e 73 78 7d 82 87 8c 91 96 9b a0 a5 aa af b4 b9 be c3 c8 cd d2 d7 dc e1 e6 eb f0 f5 fa ff
01 06 0b 10 15 1a 1f 24 29 2e 33 38 3d 42 47 4c 51 56 5b 60 65 6a 6f 74 79 7e 83 88 8d 92 97 9c a1 a6 ab b0 b5 ba bf c4 c9 ce d3 d8 dd e2 e7 ec f1 f6 fb
02 07 0c 11 16 1b 20 25 2a 2f 34 39 3e 43 48 4d 52 57 5c 61 66 6b 70 75 7a 7f 84 89 8e 93 98 9d a2 a7 ac b1 b6 bb c0 c5 ca cf d4 d9 de e3 e8 ed f2 f7 fc
03 08 0d 12 17 1c 21 26 2b 30 35 3a 3f 44 49 4e 53 58 5d 62 67 6c 71 76 7b 80 85 8a 8f 94 99 9e a3 a8 ad b2 b7 bc c1 c6 cb d0 d5 da df e4 e9 ee f3 f8 fd
04 09 0e 13 18 1d 22 27 2c 31 36 3b 40 45 4a 4f 54 59 5e 63 68 6d 72 77 7c 81 86 8b 90 95 9a 9f a4 a9 ae b3 b8 bd c2 c7 cc d1 d6 db e0 e5 ea ef f4 f9 fe
Ruby 2.4.1, bootsnap 1.1.2.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 33 (8 by maintainers)
For me, I removed bootsnap gem from the
Gemfileas well as a line of code loading bootsnap fromboot.rb. The problem solved.You can’t just
chown -R $appuser tmp/cachebefore starting?@niyando we added the ec2 user to the same group as the user who creates the app. Credit goes to @a14m.
This is the ebextensions file:
I get this error with a Rails app deployed via AWS ElasticBeanstalk whenever I want to run a rails/rake command on the EC2 instance. I couldn’t find a work-around so far.
This worked for me:
changed gemfile to
gem 'bootsnap', '>= 1.1.0', '< 1.4.2', require: falsethen run
I had this issue (
Permission denied - bs_fetch:atomic_write_cache_file:open) when upgrading my project to Rails 5.2 on Ubuntu and Nginx. Changing permissions ofcache/bootsnap-compile-cacheto 777 solved the problem - although it doesn’t sound right.On our production environment the Rails app runs as a Systemd service under a user with limited system access. If I run the console as our devops user the file permissions of the cache change and errors start popping up.
My workaround is that I skip Bootsnap in production console using:
boot.rb
It is difficult to detect console mode so early on in the Rails initialization process, but this allows us to use Bootsnap until I find a better way to work around the file permission issue.
I get these on a regular basis. I noticted it’s triggered by updating certain gems, especially gems with C extensions. The permission error also seems to be related to the Ruby VM memory and not the file system.
Anyway, after clearing the bootsnap-compile-cache directory the error always goes away (until the next bundle update 😉)
As a workaround, I was able to run rails console on AWS Beanstalk by issuing the following commands:
@burke I did some deeper digging and it feels like that my problem might be related to
umasks. I can reproduce it like this:bootsnap-compile-cachedirectoryThis way the files are generated with wrong permissions, which is not the case when I exchange steps 2 + 3. The nginx application process and normal user have different umasks which explains the problem.
I am not sure how to fix this, it feels like that our whole server setup is just messed up. On the other hand, it might be possible to bypass umask configurations as described in https://stackoverflow.com/a/39737630/745266 , but I am not sure if this is actually a good practice or not.
One thing:
If your cache was already populated; that is, all of those
00,01, etc. directories already existed – and then you ran the application as a different user without write permission to those directories – I can see this happening.This worked for me. Thank you @daniel-rikowski 😃
@burke Thank you very much, with this fix I was able to deploy bootsnap to our production system! After deleting the cache from a previous deployment, everything seems to work now! Awesome work!
I just released 1.1.7, which writes caches with 0775 and 0644. We could probably catch that error in ruby-land and raise a more descriptive error but I’m going to wait and see if anyone else complains now that group-writability is toggled on.