如何解决权限被拒绝@rb_sysopen

发布于 2025-01-12 11:36:00 字数 818 浏览 3 评论 0原文

我正在编写一个简单的食谱来创建文件:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

日暮斜阳 2025-01-19 11:36:01

您的应用似乎无权访问文件 /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

时光清浅 2025-01-19 11:36:01

Errno::EACCES 表示“权限被拒绝”

Errno 类映射到运行时的系统调用错误。您可以在以下位置找到此(令人困惑的)记录:

在特别是:

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

在大多数 *nix 系统上 Errno::EACCES 映射到 libc 错误代码表示“权限被拒绝”。具体来说:

Macro: int EACCES

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

这通常意味着您的 #create 操作没有权限读取、写入或遍历您尝试管理的文件的路径,因此您需要更改您的实现(您在原始帖子中没有显示) )以确保您的 Ruby 进程具有执行请求的操作所需的文件或文件系统权限。

另请参阅

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

那片花海 2025-01-19 11:36:01

看来您没有以 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文