Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2.3 Failed to remove file with php composer.phar update

I am following the guide on symblog: http://tutorial.symblog.co.uk/docs/doctrine-2-the-blog-model.html

I am trying to run: $ php composer.phar update after updating the composer.json but get the following error:

[Symfony\Component\Filesystem\Exception\IOException]
Failed to remove file "/var/webroot/vhosts/mysite.co.uk/htdocs/Symfony/app/cache/dev_old/profiler/32/95/639532"

The permissions on this file is: 0644 were the owner is www-data and the group is sambashare which includes the user i am ssh'd in as (john).

As this is running php from command line, is php being run as 'john' thus in the group of the file wanting to be removed but not the user?

The runtime error at the end it:

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.

After a bit of searching some people have just said clear this cache manually.. but how can i fix this issue at the root so i do not have to do this manually?

Thanks, John

like image 811
John Avatar asked Dec 30 '13 13:12

John


People also ask

How do I get a Composer Phar file?

To install Composer locally, run the installer in your project directory. See the Download page for instructions. The installer will check a few PHP settings and then download composer.phar to your working directory. This file is the Composer binary.

What is Composer Phar?

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. —

How do I update my Composer?

update / u# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.

How do I create a Composer JSON file?

To configure Composer for your PHP app json file specifies required packages. Verify that a composer. json file is present in the root of your git repository. Run composer install (on your local machine) to install the required packages and generate a composer.


2 Answers

This is a common problem with Symfony2 you should run your commands under the apache2 user in most cases this is the www-data user.

You can switch to the www-data user with

su www-data -s /bin/bash

then you should set 755 to the cache folder that the www-data has enough permissions. There is a goof explanation in the Symfony2 documentation about that.

http://symfony.com/doc/current/book/installation.html

Here in the documentation is a section "Setting up Permissions" there you can see how you can configure ACLs and other user permissions.

like image 50
René Höhle Avatar answered Nov 14 '22 21:11

René Höhle


The problem is PHP console commands use php-cli running under the current user as opposed to the web server's user (usually www-data), leading to permission errors.

The Symfony book explains several ways to avoid the issue.

like image 43
Maltronic Avatar answered Nov 14 '22 21:11

Maltronic