Symfony 4 Unable to write on cache/dev directory - symfony

I've setup a new symfony 4 project. This is running on vagrant for local development. Now I'm running into file permission issues.
Symfony itself says it should be any problem: Setting up or Fixing File Permissions.
If I run bin/console cache:clear, the code is running fine. But once I change my code, I'm getting the following error:
(1/1) IOException
Unable to write to the "/var/www/path_to_project/var/cache/dev" directory.
Running bin/console cache:clear again, code works fine. But changing the code again, same write issue again.
I tried to chmod +r 777 var/cache/dev, but that doesn't change a thing. How can I fix this?
Output for Ahmed bhs
$ ls -la var/
total 16
drwxrwxr-x 4 vagrant vagrant 136 Jan 7 11:41 ./
drwxrwxr-x 14 vagrant vagrant 476 Jan 7 12:30 ../
drwxrwxr-x 3 vagrant vagrant 102 Jan 7 12:57 cache/
drwxrwxr-x 2 vagrant vagrant 68 Jan 7 11:41 log/
$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),4(adm),24(cdrom),27(sudo),30(dip),33(www-data),46(plugdev),110(lxd),115(lpadmin),116(sambashare),998(rvm),1003(www-user)
EDIT
The problem wasn't symfony but the configuration of my vagrantfile.
Synced_folder had owner 'vagrant' while apache 'www-data'. Made all 'www-data' and now it is working fine. Totally not symfony related!

Try
sudo chmod -R 777 /var/www/path_to_project/var/cache/*

Run chmod -R 0777 var instead of running commands for separate folders.

Related

R package builds & pkgbuild::compile_dll failing; New files in /tmp are not executable

I'm attempting to build a package and install R packages that use Rccp. These are failing because files in /tmp are not executable.
These problems arose after switching to a new Dell xps 13 pre-installed with Ubuntu 18.04. For the build, I've been using pkgbuild::compile_dll to compile some C code with Rccp. I only found out about the problem installing new packages while troubleshooting the problem with compile_dll. This confirmed that its not a problem with pkgbuild.
Here is the error message from compile_dll:
> pkgbuild::compile_dll()
Registered S3 methods overwritten by 'ggplot2':
method from
[.quosures rlang
c.quosures rlang
print.quosures rlang
Re-compiling spstan
─ installing *source* package ‘spstan’ ...
** using staged installation
ERROR: 'configure' exists but is not executable -- see the 'R
Installation and Administration Manual'
─ removing
‘/home/connor/tmp/RtmpC0EMxX/devtools_install_570e38f2a7e3/spstan’
Error in (function (command = NULL, args = character(),
error_on_status = TRUE, :
System command error
There's plenty of help out there for this it seems, except that none of the solutions are working for me. Here is what I've tried.
Remount /tmp as in
https://github.com/r-lib/devtools/issues/32
Remount /tmp and enable executable files be entering the following in the terminal:
sudo mount -o remount,exec /tmp
Which gives the following error message: mount point not mounted or bad option. Since /tmp isn't mounted separately on my computer, its part of the root filesystem, the above solution fails because /tmp can't be remounted.
Following the instructions from the R Installation and Administration Manual, make sure TMPDIR points to some temporary file system in which scripts are allowed to be executed. So I made a new tmp folder called ~/Rtmp and mounted it:
mkdir ~/Rtmp
mount -t tmpfs -o exec ~/Rtmp
Also adding the following line to my ~/.Renviron file:
TMPDIR=/home/connor/Rtmp
and adding the following line to /etc/fstab:
tmpfs /home/connor/Rtmp tmpfs exec 0 0
and then rebooting the computer before running pkgbuild::compile_dll() again. I get the same error message but I could confirm that R was using /Rtmp folder I directed it to.
Following some advice here https://ubuntuforums.org/showthread.php?t=2421441 change permissions on the /tmp folder recursively with
sudo chmod -R 777 ~/tmp
This also fails. The problem seems to be that compile_dll is creating a new script that it wants to run and the permissions on the folder aren't the default for new files that get added to it.
When I print out the permissions for /tmp, the script that is failing with compile_dll is listed without the same permissions as all the older files:
drwx------ 3 connor connor 4096 Jun 23 15:20 RtmpC0EMxX
drwxrwxrwx 9 root root 4096 Jun 23 09:53 RtmpGb3QiA
drwxrwxrwx 3 connor connor 4096 Jun 23 10:44 RtmpI9hu1U
drwxrwxrwx 2 connor connor 4096 Jun 23 10:41 RtmpIgi5su
drwxrwxrwx 2 connor connor 4096 Jun 23 10:07 RtmpK4p4Od
drwxrwxrwx 4 root root 4096 Jun 23 09:17 RtmppdbqeT
drwxrwxrwx 10 root root 4096 Jun 23 09:54 RtmpR4Cc9c
drwxrwxrwx 14 root root 4096 Jun 23 10:13 Rtmpuweyxz
drwxrwxrwx 2 connor connor 4096 Jun 23 10:07 RtmpwN9SbT
drwxrwxrwx 2 connor connor 4096 Jun 23 10:04 RtmpY7g0NK
So I'm still stuck. Am I doing something wrong here? Or do I need to start looking somewhere else for the source of the problem?

Permission Denied error setting 777 folder access

I created a user with admin access named hadoop. The funny thing is that when I create a folder and try to give it 777 access it gives me back an error.
hadoop#linux:~$ mkdir testfolder
hadoop#linux:~$ ls -ltra testfolder/
total 8
drwxrwxrwx 25 hadoop sudo 4096 Jun 14 20:00 ..
drwxrwxr-x 2 hadoop hadoop 4096 Jun 14 20:00 .
hadoop#linux:~$ chmod -777 -R
testfolder/ chmod: cannot read directory ‘testfolder/’: Permission denied
Why is that when I am the creator of the directory ?
hadoop#linux:~$ groups
hadoop root sudo
Strangely, using the GUI, I can go in and right click the directory and change the file permissions. Can anyone help me understand what i am not understanding.
Note : I use Ubuntu 14
Your command chmod -777 -R testfolder/ is the issue here, more specific the - as part of the first argument.
Leave it away, just use chmod 777 -R testfolder/ and all should be fine...
Not exactly sure about the details, but the -777 should remove permissions, thus preventing access at least to the recursive portion of the command. I assume that is not what you want to do. Instead you probably want to grant more permissions to the directory. Looks like the command blocks itself. Though that might be by purpose, at least in an indirect manner.

403 Error on Stylesheet - Raspberry Pi Webserver

I keep seeing a 403 error for my stylesheet which is hosted on my Rasberry Pi (webserver). I ran ls -al and this is the result:
pi#raspberrypi ~/www $ ls -al
total 16
drwxr-xr-x 2 pi root 4096 Mar 17 20:18 .
drwxr-xr-x 12 root root 4096 Mar 15 16:44 ..
-rw-r--r-- 1 pi root 644 Mar 17 20:18 index.html
-rw------- 1 pi root 329 Mar 17 20:19 stylesheet.css
The index.html data shows up when I point my browser at the ip, but there is no formatting and whenever I try to acess the css file through looking at the source code it keeps telling me theres a 403 error :(
Can anyone help a brother out??
Cheers!
You need proper permissions for the www folder, and that depends on which webserver you are running. For apache on debian the user is www-data, if your webroot is ~/www and you are user pi try these commands
Change owner to apache user recursively
Change Permissions to read for all recursively
chown -R www-data:www-data /home/pi/www
chmod -R 644 /home/pi/www

Permission denied on SBT installation

So I "installed" SBT by following directions here under the "UNIX" section by downloading the jar and creating the sbt script to run it - however instead of putting it in ~/bin/ I put it in /usr/local/sbt/. I added it to my PATH variable and when I try to run it without sudo I get a Permission denied error (below). Also below is what I see when I type in ls -l in the sbt directory.
$ sbt compile
bash: /usr/local/sbt/sbt: Permission denied
-rwxrwxr-- 1 root wheel 120 Jun 20 09:21 sbt*
-rwxrwxr--# 1 adelbertc staff 1096763 Jun 20 09:20 sbt-launch.jar*
Help?
Try changing the permissions so that you can execute it:
sudo chmod o+x /usr/local/sbt/sbt /usr/local/sbt/sbt-launch.jar
Otherwise, you can add yourself to the wheel group, or change the owner so that you own it:
sudo chown adelbertcs:staff /usr/local/sbt/sbt
(assuming that your username is adelbertcs).

File system permission error while installing drupal modules

When I try to install new modules to drupal 7 via "Install new module" form, I get following error message.
The specified file
temporary://fileTFJ015 could not be
copied, because the destination
directory is not properly configured.
This may be caused by a problem with
file or directory permissions. More
information is available in the
system log.
http://ftp.drupal.org/files/projects/date-7.x-1.0-alpha2.tar.gz
could not be saved to
temporary://update-cache/date-7.x-1.0-alpha2.tar.gz.
Unable to retrieve Drupal project
from
http://ftp.drupal.org/files/projects/date-7.x-1.0-alpha2.tar.gz.
My Drupal 7 is installed with CPanel QuickInstall tool and hosted with HostGator shared hosting service.
Any ideas how to solve this issue?
There is an issue with shared hosts and temp folders...if you want the background you can read this:
http://drupal.org/node/1008328
in the meantime try changing your tmp folder to be relative to your sites file root:
sites/default/files/temp
The quickest way to get a handle on this issue is to navigate via your web browser to:
/admin/config/media/file-system
You'll probably see an error there about not being able to write to the /tmp directory. To fix this, you can create a temp directory under site's root and set permissions appropriately.
1) Create a directory here [drupal_installed_here]/tmp
2) Navigate via your web browser to /admin/config/media/file-system and change the temp directory to be:
tmp instead of /tmp (no leading slash)
3) Try this command:
chmod 775 [drupal_istalled_here]/tmp
and refresh the /admin/config/media/file-system page
3) If that does not work, try this command:
chmod 777 /home/quickstart/websites/tmp
and refresh the /admin/config/media/file-system page
The last command opens up your temp directory permissions a lot (rwxrwxrwx), but sometimes that's necessary to get your site working on shared hosts.
This error took me a long time to figure out despite several threads on the internet related to it.
If you get this error on a page, then here are the steps that you need to follow to solve it:
Go to Admin->Reports->Recent Log Messages. Read the most recent error message. This will tell you which folder is causing the problem. It is not necessarily the directory listed in the online threads about this subject. For me it was: sites/default/files/js
If you are running Drupal on a linux server then you need to add read/write permissions to the problem folder. You can do this by going to the linux/SSH command line and typing the following (replace the folder address with the address for your folder)
chmod 777 /var/www/html/sites/default/files/js
That's it. The error message should be gone now.
My old, problematic configuration:
chmod 664 -R /var/drupal-bc/sites/default/files
chmod 664 -R /var/drupal-bc/sites/default/private
drw-rw-r-- 2 www-data www-data 4096 Jul 31 12:35 files
drw-rw-r-- 3 www-data www-data 4096 Jul 5 15:08 private
My new, functional configuration:
chmod 774 -R /var/drupal-bc/sites/default/files
chmod 774 -R /var/drupal-bc/sites/default/private
drwxrwxr-- 2 www-data www-data 4096 Jul 31 12:35 files
drwxrwxr-- 3 www-data www-data 4096 Jul 5 15:08 private
Please do not use 777 permissions, because you will have security problems. 775 will do just fine.
chmod 775 -R /var/drupal-bc/sites/default/files
chmod 775 -R /var/drupal-bc/sites/default/private
If you have javascript caching turned on, you might need to 755 the /sites/all/your-theme/js
chmod 777 /var/www/html/sites/default/files/js
solved the issue for me

Resources