Permission denied @ dir_s_mkdir - /rails/tmp/sockets (Errno::EACCES)

Hallo everyone! Im new in development and I trying to deploy my first app. For example, when I run "fly deploy", I have got an error: INFO Starting init (commit: 0b28cec)... INFO starting statics vsock server INFO Preparing to run: /rails/bin/docker-entrypoint ./bin/rails serveras rails INFO [fly api proxy] listening at /.fly/api 2023/06/24 09:22:16 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53) => Booting Puma => Rails 7.0.5 application starting in production => Runbin/rails server --helpfor more startup options Exiting /usr/local/lib/ruby/3.1.0/fileutils.rb:243:inmkdir’: Permission denied @ dir_s_mkdir - /rails/tmp/sockets (Errno::EACCES)
from /usr/local/lib/ruby/3.1.0/fileutils.rb:243:in fu_mkdir' from /usr/local/lib/ruby/3.1.0/fileutils.rb:221:in block (2 levels) in mkdir_p’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:219:in reverse_each' from /usr/local/lib/ruby/3.1.0/fileutils.rb:219:in block in mkdir_p’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:211:in each' from /usr/local/lib/ruby/3.1.0/fileutils.rb:211:in mkdir_p’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:71:in block in create_tmp_directories' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:70:in each’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:70:in create_tmp_directories' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:34:in start’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:143:in block in perform' from <internal:kernel>:90:in tap’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:134:in perform' from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in run’
from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in invoke_command' from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in dispatch’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/command/base.rb:87:in perform' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/command.rb:48:in invoke’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands.rb:18:in <main>' from <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in require’
from internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb:37:in require' from /rails/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require’
from /rails/bin/rails:4:in `’
INFO Main child exited normally with code: 1
INFO Starting clean up.
WARN hallpass exited, pid: 232, status: signal: 15 (SIGTERM)
2023/06/24 09:22:19 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53)
Error: smoke checks for 918571e9b17783 failed: the app appears to be crashing.

On my local machine all Users have Full control for this directory. What I doing wrong?

Inside your Dockerfile there should be a line that looks like:

    chown -R rails:rails db log storage tmp /data

If that line is not there, try:

bundle update dockerfile-rails
bin/rails generate dockerfile
1 Like

Thanks for your answer! I`ve done all you said and my Dockerfile has a line:

RUN useradd rails --create-home --shell /bin/bash &&
chown -R rails:rails db log storage tmp
USER rails:rails

Then run fly deploy again and have the same error(((

Exiting
/usr/local/lib/ruby/3.1.0/fileutils.rb:243:in mkdir': Permission denied @ dir_s_mkdir - /rails/tmp/sockets (Errno::EACCES) from /usr/local/lib/ruby/3.1.0/fileutils.rb:243:in fu_mkdir’

WARN hallpass exited, pid: 232, status: signal: 15 (SIGTERM)
2023/06/24 11:47:15 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53)
[ 4.150781] reboot: Restarting system
Error: smoke checks for 918571e9b17783 failed: the app appears to be crashing

None of this makes any sense, but perhaps the following will give you something to look for. The rails code in question:

Note that it tries to create three directories, and you are failing on the third one, so presumably it must have been able to create the first two. The error you are getting is a permission failure which doesn’t make sense as the dockerfile chown’s the parent directory.

If the tmp/sockets directory exists on your local machine, delete it. Your source is uploaded minus the files listed in .dockerignore, which should contain:

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

Hi, I deleted tmp/sockets directory but problem still exist.
When I run fly deploy
deployment-01H3VYB3G6AF843WWZ9A3GD68X: digest: sha256:013ded0eb15170553201bac0f585cbc87c7ce495a4666f348bfbc98d9b84bd18 size: 3054
→ Pushing image done
image: registry.fly.io/health-clinic:deployment-01H3VYB3G6AF843WWZ9A3GD68X
image size: 688 MB

Watch your app at Sign In · Fly

Updating existing machines in ‘health-clinic’ with rolling strategy
Machine 918571e9b17783 [app] has state: started
[1/1] Checking that 918571e9b17783 [app] is up and running
Smoke checks for 918571e9b17783 failed: the app appears to be crashing
Check its logs: here’s the last lines below, or run ‘fly logs -i 918571e9b17783’:
Successfully prepared image registry.fly.io/health-clinic:deployment-01H3VYB3G6AF843WWZ9A3GD68X (1.471034896s)
Configuring firecracker
INFO Starting init (commit: 0b28cec)…
INFO starting statics vsock server
INFO Preparing to run: /rails/bin/docker-entrypoint ./bin/rails server as rails
INFO [fly api proxy] listening at /.fly/api
2023/06/26 13:30:13 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53)
=> Booting Puma
=> Rails 7.0.5 application starting in production
=> Run bin/rails server --help for more startup options
Exiting
/usr/local/lib/ruby/3.1.0/fileutils.rb:243:in mkdir': Permission denied @ dir_s_mkdir - /rails/tmp/sockets (Errno::EACCES) from /usr/local/lib/ruby/3.1.0/fileutils.rb:243:in fu_mkdir’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:221:in block (2 levels) in mkdir_p' from /usr/local/lib/ruby/3.1.0/fileutils.rb:219:in reverse_each’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:219:in block in mkdir_p' from /usr/local/lib/ruby/3.1.0/fileutils.rb:211:in each’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:211:in mkdir_p' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:71:in block in create_tmp_directories’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:70:in each' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:70:in create_tmp_directories’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:34:in start' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:143:in block in perform’
from internal:kernel:90:in tap' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:134:in perform’
from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in run' from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in invoke_command’
from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in dispatch' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/command/base.rb:87:in perform’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/command.rb:48:in invoke' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands.rb:18:in
from internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb:37:in require' from <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in require’
from /rails/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' from /rails/bin/rails:4:in
INFO Main child exited normally with code: 1
INFO Starting clean up.
WARN hallpass exited, pid: 232, status: signal: 15 (SIGTERM)
2023/06/26 13:30:16 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53)
[ 4.141022] reboot: Restarting system
machine did not have a restart policy, defaulting to restart
INFO Starting init (commit: 0b28cec)…
INFO starting statics vsock server
INFO Preparing to run: /rails/bin/docker-entrypoint ./bin/rails server as rails
INFO [fly api proxy] listening at /.fly/api
2023/06/26 13:30:18 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53)
=> Booting Puma
=> Rails 7.0.5 application starting in production
=> Run bin/rails server --help for more startup options
Exiting
/usr/local/lib/ruby/3.1.0/fileutils.rb:243:in mkdir': Permission denied @ dir_s_mkdir - /rails/tmp/sockets (Errno::EACCES) from /usr/local/lib/ruby/3.1.0/fileutils.rb:243:in fu_mkdir’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:221:in block (2 levels) in mkdir_p' from /usr/local/lib/ruby/3.1.0/fileutils.rb:219:in block in mkdir_p’
from /usr/local/lib/ruby/3.1.0/fileutils.rb:211:in each' from /usr/local/lib/ruby/3.1.0/fileutils.rb:211:in mkdir_p’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:71:in block in create_tmp_directories' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:70:in each’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:70:in create_tmp_directories' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:34:in start’
from internal:kernel:90:in tap' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands/server/server_command.rb:134:in perform’
from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor/command.rb:27:in run' from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in invoke_command’
from /rails/vendor/bundle/ruby/3.1.0/gems/thor-1.2.2/lib/thor.rb:392:in dispatch' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/command/base.rb:87:in perform’
from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/command.rb:48:in invoke' from /rails/vendor/bundle/ruby/3.1.0/gems/railties-7.0.5/lib/rails/commands.rb:18:in
from internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb:37:in require' from <internal:/usr/local/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in require’
from /rails/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' from /rails/bin/rails:4:in
INFO Main child exited normally with code: 1
WARN hallpass exited, pid: 232, status: signal: 15 (SIGTERM)
2023/06/26 13:30:21 listening on [fdaa:2:54cf:a7b:18e:e027:d22:2]:22 (DNS: [fdaa::3]:53)
Error: smoke checks for 918571e9b17783 failed: the app appears to be crashing

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.