如何解决权限被拒绝@rb_sysopen
我正在编写一个简单的食谱来创建文件:
file '/myfile' do
content 'Welcome to Technical Guftgu'
action :create
end
但是在 Chef-client -zr "recipe[test::recipe1]" 上,我收到以下错误:
[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
I am writing a simple recipe to create a file:
file '/myfile' do
content 'Welcome to Technical Guftgu'
action :create
end
But on chef-client -zr "recipe[test::recipe1]" I am getting the 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的应用似乎无权访问文件
/myfile
。试试这个,允许访问所有内容:
sudo chmod a+rw /myfile
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
Errno::EACCES 表示“权限被拒绝”
Errno 类映射到运行时的系统调用错误。您可以在以下位置找到此(令人困惑的)记录:
在特别是:
在大多数 *nix 系统上 Errno::EACCES 映射到 libc 错误代码表示“权限被拒绝”。具体来说:
这通常意味着您的 #create 操作没有权限读取、写入或遍历您尝试管理的文件的路径,因此您需要更改您的实现(您在原始帖子中没有显示) )以确保您的 Ruby 进程具有执行请求的操作所需的文件或文件系统权限。
另请参阅
errno.h
来自 开放组基础规范第 7 期,2018 年版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:
on most *nix sytems Errno::EACCES maps to the libc error code for "permission denied". Specifically:
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
errno.h
from The Open Group Base Specifications Issue 7, 2018 edition看来您没有以 root 用户身份执行此操作,请通过键入 sudo su 将其更改为 root,然后重新运行该命令,希望这会有所帮助。
我遇到了同样的问题,卡住了一个小时,然后就成功了。
it seems you are not executing this as a root user, change it to root by typing sudo su then rerun the command, hopefully this will help.
I was facing the same issue and stuck for an hour, just did it and succeeded.