Skip to content

"IOException: Failed to chmod file" on FS without chmod #8205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Salvat opened this issue Jun 5, 2013 · 20 comments
Closed

"IOException: Failed to chmod file" on FS without chmod #8205

Salvat opened this issue Jun 5, 2013 · 20 comments

Comments

@Salvat
Copy link

Salvat commented Jun 5, 2013

Hello,

we use a shared network drive where all projects are hosted.
The File System mounts an external drive and so every file is chmod 777 and writable.

On Symfony 2.3 we get the following error before we can even configure the Instance:

IOException: Failed to chmod file /Symfony/app/cache/dev/appDevDebugProjectContainer.xml
in /Symfony/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php line 177
at Filesystem->chmod('/Symfony/app/cache/dev/appDevDebugProjectContainer.xml', '436') in /Symfony/vendor/symfony/symfony/src/Symfony/Component/Filesystem/Filesystem.php line 469
at Filesystem->dumpFile('/Symfony/app/cache/dev/appDevDebugProjectContainer.xml', '<% CONFIG_XML_DATA_A_PAGE_LONG %>' 

We didn't get that problem in Symfony 2.2.

@fabpot
Copy link
Member

fabpot commented Jun 13, 2013

Indeed, the Filesystem class silently ignored errors in 2.2, whereas we throw exceptions now in 2.3. I don't know what to do here. Can we safely ignore such problems when writing files in the cache?

@Jaza
Copy link

Jaza commented Jul 5, 2013

On my local machine, I have the same problem (my Symfony codebase is on an NTFS drive, for Windows compatibility, mounted in Ubuntu with 777 perms for al files).

I fixed this locally, by just commenting out the line of code that raises an exception on chmod errors:

File: src/Symfony/Component/Filesystem/Filesystem.php
Line: 177

Change:
throw new IOException(sprintf('Failed to chmod file %s', $file));

To:
//throw new IOException(sprintf('Failed to chmod file %s', $file));

This works for me (since all my files are 777, I don't care about a chmod exception, there's no way logically that it could affect me). However, this is not a nice solution. Perhaps if there was some way of checking if the volume in question supports chmod'ing, and if it doesn't then don't bother to raise an exception... that would help? But I have no idea if such a check is possible.

@fabpot
Copy link
Member

fabpot commented Jul 8, 2013

This bug is due to 3158c41, which took the wrong approach.

@mpdude
Copy link
Contributor

mpdude commented Jul 8, 2013

That was my commit :-(

https://github.com/symfony/symfony/blob/2.2/src/Symfony/Component/Config/ConfigCache.php#L106 -> previously, the chmod() was considered optional to success and errors were silenced.

@mpdude
Copy link
Contributor

mpdude commented Jul 8, 2013

@fabpot
Copy link
Member

fabpot commented Jul 8, 2013

That looks wrong to me as you might want to have the exception. In the case of cache generation, we don't care, but it might be of importance somewhere else. The safest is probably just to revert the changes made and keep the Filesystem::dumpFile for BC reasons.

@mpdude
Copy link
Contributor

mpdude commented Jul 9, 2013

Thought about it, but what I had in mind was breaking BC :(

One possibility left would be an exception subclass for a failing chmod so we could catch and ignore that when dumping a ConfigCache.

@fabpot
Copy link
Member

fabpot commented Jul 9, 2013

@mpdude Having a subclass exception looks overkill to me. This code should be as simple as possible. So, reverting the culprit is probably the best option.

@brad-d
Copy link

brad-d commented Jul 23, 2013

I'm also getting this issue when in OSX on a truecrypt mounted drive. It works when I use the regular hard disk mount. They both use the same filesystem (HFS), so I think it's because one of them is mounted by my user instead of the system.

Additionally, if I comment the line that throws an exception I get:
file_get_contents(/Volumes/Gyges/symfony/app/cache/dev/classes.php.meta): failed to open stream: Permission denied in /Volumes/Gyges/symfony/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php line 71

@ikodev
Copy link

ikodev commented Aug 1, 2013

I just met the same problem. My project is accessed via a samba share and I wanted to add the Symfony command line tool in PhpStorm, but adding it returned me : IOException: Failed to chmod file /Symfony/app/cache/dev/appDevDebugProjectContainer.xml.

I solved (temporarily?) the problem by re-fixing the ACLs default permissions of my specific unix group for development on the entire project (rwx).

@Acorath
Copy link

Acorath commented Nov 20, 2013

I'm currently setup on Windows which is where all of my source files are located. My guest machine is Linux (Ubuntu 12.04) using Samba to mount web directories from the host. My original mount directive specified my user account as the owner and www-data as the group. Switching the owner to www-data fixed this error for me...

File: /etc/fstab

//host/www /media/www cifs credentials=/home/myuser/.smbcreds,uid=www-data,gid=www-data,file_mode=0664,dir_mode=0775 0 0

@aljinovic
Copy link

Will this be fixed in 2.4?

@mvar
Copy link
Contributor

mvar commented Dec 18, 2013

Problem still exists in version 2.4. Any new ideas how to fix it?

@jakzal
Copy link
Contributor

jakzal commented Jan 4, 2014

@fabpot should we revert 3158c41?

@natebrunette
Copy link

Is there a workaround for this? I'm on OSX developing on a mounted partition.

@jakzal
Copy link
Contributor

jakzal commented Jan 13, 2014

@mpdude or maybe you have another idea on how to fix it?

@lavoiesl
Copy link
Contributor

Perhaps you could add support for $mode = null which would deactivate the chmod. This way, cache generation would not set permissions. One needing to protect its cache directory could manually chmod the folder itself.

@alexandresalome
Copy link

Problem still occurs, I'm hitting it right now.

Can we consider reverting the commit that broke backward compatibility?

@noofaq
Copy link

noofaq commented Mar 7, 2014

In latest symfony 2.4.2 problem still appears. What is quite strange I have two working environment (home & office) configured in the same way, and I am experiencing this only in home. The best way to reproduce this is to make 2-3 request simulatenously and some of those request will fail.

My configuration is similar to @Acorath : guest machine is Ubuntu, which uses sources mounted via cifs (and windows file sharing on the second side)

//PIOTR-HOME/vhosts/centos6 /var/www/vhosts cifs user=vbox,pass=,uid=apache,gid=apache,file_mode=0777,dir_mode=0777 0 0

PS. setting 0777 chmod does not help

@noofaq
Copy link

noofaq commented Mar 17, 2014

I have found tricky solution for this (what also gives visible performance improvement):

//PIOTR-HOME/vhosts/centos6 /var/www/vhosts cifs user=vbox,pass=<password>,uid=apache,gid=apache,file_mode=0777,dir_mode=0777 0 0
tmpfs                   /var/www/vhosts/symfony2-project/app/cache tmpfs rw,size=64m 0 0

This additional line mounts the cache folder as native unix ramfs. It solves the problem in some kind of "hacky" way (but works).

NOTICE! If you have profiler enabled, it can consume really significant amount of space for its caches so I suggest to modify the size of ramfs according to your needs.

romainneutron added a commit to romainneutron/symfony that referenced this issue Mar 19, 2014
fabpot pushed a commit to fabpot/symfony that referenced this issue Mar 26, 2014
fabpot added a commit that referenced this issue Mar 26, 2014
… chmod support (fabpot)

This PR was merged into the 2.3 branch.

Discussion
----------

Fixed regression when using Symfony on filesystems without chmod support

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8205
| License       | MIT
| Doc PR        | n/a

Commits
-------

cefb67a Fix #8205 : Deprecate file mode update when calling dumpFile
@fabpot fabpot closed this as completed Mar 26, 2014
fabpot added a commit that referenced this issue Mar 26, 2014
* 2.3: (34 commits)
  Fix #8205 : Deprecate file mode update when calling dumpFile
  Fix #10437: Catch exceptions when reloading a no-cache request
  Fix libxml_use_internal_errors and libxml_disable_entity_loader usage
  removed ini check to make uploadedfile work on gae
  Update OptionsResolver.php
  fixed comment in forms.xml file
  Clean KernelInterface docblocks
  Cast the group name as a string
  Fixed doc of InitAclCommand
  [Form] Fix "Array was modified outside object" in ResizeFormListener.
  Fix IBAN validator
  [Process] Remove unreachable code + avoid skipping tests in sigchild environment
  Fixed bug that incorrectly causes the "required" attribute to be omitted from select even though it contains the "multiple" attribute
  Added travis_retry to .travis.yml
  [Process] fix some typos and refactor some code
  [Process] Fix unit tests in sigchild disabled environment
  [Process] Trow exceptions in case a Process method is supposed to be called after termination
  fixed typo
  [Process] fixed fatal errors in getOutput and getErrorOutput when process was not started
  [Process] Fix escaping on Windows
  ...

Conflicts:
	src/Symfony/Component/DomCrawler/Crawler.php
	src/Symfony/Component/Filesystem/Filesystem.php
	src/Symfony/Component/Process/Process.php
fabpot added a commit that referenced this issue Mar 26, 2014
* 2.4: (52 commits)
  Fix #8205 : Deprecate file mode update when calling dumpFile
  Fix #10437: Catch exceptions when reloading a no-cache request
  Fix libxml_use_internal_errors and libxml_disable_entity_loader usage
  removed ini check to make uploadedfile work on gae
  Update OptionsResolver.php
  fixed comment in forms.xml file
  Clean KernelInterface docblocks
  Cast the group name as a string
  Fixed doc of InitAclCommand
  [Form] Fix "Array was modified outside object" in ResizeFormListener.
  Fix IBAN validator
  [Process] Remove unreachable code + avoid skipping tests in sigchild environment
  Fixed bug that incorrectly causes the "required" attribute to be omitted from select even though it contains the "multiple" attribute
  Added travis_retry to .travis.yml
  [Process] fix some typos and refactor some code
  [Process] Fix unit tests in sigchild disabled environment
  [Process] Trow exceptions in case a Process method is supposed to be called after termination
  fixed typo
  [Process] fixed fatal errors in getOutput and getErrorOutput when process was not started
  [Process] Fix escaping on Windows
  ...

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php
	src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
	src/Symfony/Component/Process/Process.php
	src/Symfony/Component/Process/ProcessPipes.php
	src/Symfony/Component/Process/Tests/AbstractProcessTest.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests