简体   繁体   中英

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:

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.

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

Hacked around this by doing chmod 777 on the tmp directory so I am guessing it is my ignorance on the user/permissions settings.

I found this post when I encountered this error and running chmod 777 is not the solution here.

You need to do some research on how to enable group permissions and configure apaches settings appropriately. Here is a Stack Exchange thread that details this rather well and contains useful links. Make sure apache has read, write and execute access to the appropriate directories but don't simply let ANYONE modify the directory. 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. Link to Stack Exchange thread regarding apache permissions and permissions in general

I deleted the tmp folder completely, that worked for me. It just gets regenerated by the web server.

对我来说它很有用:

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.

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

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.

Each time I run the command rails assets:clobber to remove the old assets in public/assets completely, I get the error:

errno::enotempty: directory not empty @ dir_s_rmdir

errno::eacces: permission denied @ apply2files

And the logs pointed the path to the file causing it, which in my a case was the public/packs/manifest.json file.

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.

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:

-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:

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:

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.

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!

在 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:

$ sudo setenforce 0

To make the change permanent one has to change the settings in the /etc/selinux/config file:

SELINUX=disabled

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM