简体   繁体   English

Rails 错误::EACCES 权限被拒绝

[英]Rails Errno::EACCES Permission Denied

Rails 3.1 Passenger on Apache Development environment When I go to access the index (ie GET) for a route I get: Apache 开发环境中的 Rails 3.1 乘客当我访问索引(即 GET)时,我得到:

Errno::EACCES in Crb_agendas#index

Showing /var/www/crbagenda/app/views/layouts/application.html.erb where line #5 raised:

Permission denied - /var/www/crbagenda/tmp/cache/assets/E2C

Extracted source (around line #5):

2: <html>
3: <head>
4:   <title>CrbAgendas</title>
5:   <%= stylesheet_link_tag "application" %>
6:   <%= javascript_include_tag "application" %>
7:   <%= csrf_meta_tags %>
8: </head>

Rails.root: /var/www/crbagenda

When I go to the path mentioned (/var/www/crbagenda/tmp/cache/assets/E2C) there is no E2C folder and root (what apache is running as) owns the assets dir... not sure what I did wrong here.... or what else I could show to help.当我转到提到的路径 (/var/www/crbagenda/tmp/cache/assets/E2C) 时,没有 E2C 文件夹,root(apache 运行的方式)拥有资产目录......不知道我做错了什么在这里......或者我还能展示什么来帮助。

Update: Yeah this answer came from ignorance and then seemed to gain traction.更新:是的,这个答案来自无知,然后似乎受到了关注。 Anyway, the real answer can be found in Austen Tomek's answer无论如何,真正的答案可以在Austen Tomek 的答案中找到

Hacked around this by doing chmod 777 on the tmp directory so I am guessing it is my ignorance on the user/permissions settings.通过在 tmp 目录上执行 chmod 777 来解决这个问题,所以我猜这是我对用户/权限设置的无知。

I found this post when I encountered this error and running chmod 777 is not the solution here.当我遇到这个错误并且运行chmod 777不是这里的解决方案时,我发现了这篇文章。

You need to do some research on how to enable group permissions and configure apaches settings appropriately.您需要对如何启用组权限和适当配置 apaches 设置进行一些研究。 Here is a Stack Exchange thread that details this rather well and contains useful links.这是一个 Stack Exchange 线程,其中详细介绍了这一点并包含有用的链接。 Make sure apache has read, write and execute access to the appropriate directories but don't simply let ANYONE modify the directory.确保 apache 具有对适当目录的读取、写入和执行访问权限,但不要简单地让任何人修改目录。 Locate your systems apache group and run chown and chmod -g+[What permissions apache needs goes here] I would suggest not running this with the -R option and to actively look into which permission apache needs for specific directories.找到您的系统 apache 组并运行chownchmod -g+[What permissions apache needs goes here]我建议不要使用-R选项运行它,并积极查看 apache 对特定目录需要哪些权限。 Link to Stack Exchange thread regarding apache permissions and permissions in general 链接到关于 apache 权限和一般权限的 Stack Exchange 线程

I deleted the tmp folder completely, that worked for me.我完全删除了 tmp 文件夹,这对我有用。 It just gets regenerated by the web server.它只是由 Web 服务器重新生成。

对我来说它很有用:

sudo chown -R username app_path

只需在项目文件夹上运行 chown

chown -R www-data /var/www/

Im using windows vs code with a ubuntu subsystem as the terminal.我使用 windows vs code 和 ubuntu 子系统作为终端。

I had to move my project folder from the ubuntu sub system area to the windows area.. so everytime I run stuff with ubuntu I have to type cd /mnt/c/projects/my_app我不得不将我的项目文件夹从 ubuntu 子系统区域移动到 windows 区域..所以每次我用 ubuntu 运行东西我都必须输入cd /mnt/c/projects/my_app

it seems to allow the apps to run and the db/ server stuff to operate alright..它似乎允许应用程序运行并且数据库/服务器的东西运行正常..

Rhys里斯

I had this same issue when working on a Rails 6 application in Ubuntu 20.04.我在 Ubuntu 20.04 中处理 Rails 6 应用程序时遇到了同样的问题。

Each time I run the command rails assets:clobber to remove the old assets in public/assets completely, I get the error:每次我运行命令rails assets:clobber以完全删除public/assets中的旧资产时,我都会收到错误消息:

errno::enotempty: directory not empty @ dir_s_rmdir errno::enotempty: 目录不为空@dir_s_rmdir

errno::eacces: permission denied @ apply2files errno::eacces: 权限被拒绝 @ apply2files

And the logs pointed the path to the file causing it, which in my a case was the public/packs/manifest.json file.并且日志指向导致它的文件的路径,在我的情况下是public/packs/manifest.json文件。

I tried deleting it or changing permission but nothing worked.我尝试删除它或更改权限,但没有任何效果。 I also tried deleting the tmp directory in the project, but it did not work.我也试过删除项目中的tmp目录,但是没有用。

Here's how I fixed it :这是我修复它的方法

I listed all the files and directories in that directory using the ls -lh command, which gave me this output:我使用ls -lh命令列出了该目录中的所有文件和目录,该命令为我提供了以下输出:

-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 1.7K Oct  6 20:29 404.html
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 1.7K Oct  6 20:29 422.html
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem 1.6K Oct  6 20:29 500.html
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem    0 Oct  6 20:29 apple-touch-icon.png
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem    0 Oct  6 20:29 apple-touch-icon-precomposed.png
drwxr-xr-x 3 promisechukwuenyem promisechukwuenyem 4.0K Oct 13 09:20 armstrong_tools
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem    0 Oct  6 20:29 favicon.ico
drwxr-xr-x 3 root               root               4.0K Oct  8 13:06 packs
-rw-rw-r-- 1 promisechukwuenyem promisechukwuenyem   99 Oct  6 20:29 robots.txt

I realized that the packs directory had root ownership which was seperate from persmission of other files and directories:我意识到packs目录具有与其他文件和目录的权限分开的root所有权:

drwxr-xr-x 3 root               root               4.0K Oct  8 13:06 packs

I simply ran the command below to change the ownership from root to promisechukwuenyem:我只是运行下面的命令将所有权从 root 更改为 promisechukwuenyem:

sudo chown -R promisechukwuenyem:promisechukwuenyem packs/

Now when I ran the command rails assets:clobber to remove the old assets in public/assets completely, it worked just fine.现在,当我运行 command rails assets:clobber以完全删除public/assets中的旧资产时,它工作得很好。

That's all.就这样。

I hope this helps我希望这有帮助

Thanks to the posts above, I got to solve my own problem too.感谢上面的帖子,我也必须解决我自己的问题。 Personally, an important folder was labeled "Hidden" (follow the ERROR path Error: Permission denied - .../_netrc (Errno::EACCES) As soon as I right-clicked and set its folder options to NOT HIDDEN, then everything worked fine!就个人而言,一个重要的文件夹被标记为“隐藏”(按照错误路径错误:权限被拒绝 - .../_netrc (Errno::EACCES) 一旦我右键单击并将其文件夹选项设置为 NOT HIDDEN,然后一切正常美好的!

在 Windows 上,只需以管理员身份打开您的 cmd 并执行您的gem install "lib"命令

In my case changing rights nor ownership of the directory didn't help (well it was necessary).在我的情况下,更改目录的权限或所有权无济于事(这必要的)。 Turned out that Selinux kicked in (by default enabled in Fedora) and disabling was the cure:原来Selinux启动了(默认情况下在 Fedora 中启用)并禁用是治疗方法:

$ sudo setenforce 0

To make the change permanent one has to change the settings in the /etc/selinux/config file:要使更改永久化,必须更改/etc/selinux/config文件中的设置:

SELINUX=disabled

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails - Errno :: EACCES:权限被拒绝 - Rails - Errno::EACCES: Permission denied Rails和Paperclip Errno :: EACCES权限被拒绝 - Rails and Paperclip Errno::EACCES Permission denied Rails-IMGkit-Errno :: EACCES权限被拒绝错误 - Rails - IMGkit - Errno::EACCES Permission denied error Rails 3 + PDFKit问题:权限被拒绝(Errno :: EACCES) - Rails 3 + PDFKit Problem: Permission denied (Errno::EACCES) cloud9,rails s,权限被拒绝-bind(2)(Errno :: EACCES) - cloud9,rails s, Permission denied - bind(2) (Errno::EACCES) Ruby on Rails:Errno :: EACCES(权限被拒绝-oo_26502 - Ruby on Rails : Errno::EACCES (Permission denied - oo_26502 Errno :: EACCES:在Rails上创建新应用程序ruby的权限被拒绝 - Errno::EACCES: Permission denied in create new app ruby on rails 权限被拒绝 - bind(2) Errno::EACCES(Ruby on Rails,PostgreSQL 上的 Webpack) - Permission denied - bind(2) Errno::EACCES (Ruby on Rails, Webpack on PostgreSQL) Rails:权限被拒绝-“ 127.0.0.1”端口3000(Errno :: EACCES)的bind(2) - Rails: Permission denied - bind(2) for “127.0.0.1” port 3000 (Errno::EACCES) Ruby on Rails:权限被拒绝-“ 0.0.0.0”端口80(Errno :: EACCES)的bind(2) - Ruby on Rails: Permission denied - bind(2) for “0.0.0.0” port 80 (Errno::EACCES)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM