Home > Blockchain >  How to resolve permission denied @ rb_sysopen
How to resolve permission denied @ rb_sysopen

Time:03-09

I am writing a simple recipe to create file like:

file '/myfile' do
  content 'Welcome to Technical Guftgu'
  action :create
end

but on chef-client -zr "recipe[test::recipe1]" i am getting the following error:

[2022-03-08T10:54:16 00:00] ERROR: Running exception handlers
Running handlers complete
[2022-03-08T10:54:16 00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 02 seconds
[2022-03-08T10:54:16 00:00] FATAL: Stacktrace dumped to /home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2022-03-08T10:54:16 00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2022-03-08T10:54:16 00:00] FATAL: Errno::EACCES: file[/myfile] (test::recipe1 line 7) had an error: Errno::EACCES: Permission denied @ rb_sysopen - /myfile

CodePudding user response:

It seems that your app does not have access to the file /myfile.

Try this, to allow access to all: sudo chmod a rw /myfile

CodePudding user response:

Errno::EACCES Means "Permission Denied"

The Errno class is mapped to your system call errors at runtime. You can find this (confusingly) documented in:

In particular:

Errno.constants.include? :EACCES
#=> true

on most *nix sytems Errno::EACCES maps to the libc error code for "permission denied". Specifically:

Macro: int EACCES

    "Permission denied." The file permissions do not allow the attempted operation. 

That generally means your #create action doesn't have permissions to read, write, or traverse the path to the file you are trying to manage, so you need to change your implementation (which you don't show in your original post) to ensure that your Ruby process has the needed file or filesystem permissions to perform the requested operations.

See Also

  • Related