When I ran composer update it failed, with an error like this:
Patching is disabled. Skipping.
- Removing symfony/http-foundation (v2.8.15)
Update failed (Could not delete /path-to-website/vendor/symfony/http-foundation/Cookie.php
I had created a user on my server - called "web" with the permissions correct for deleting the file (and containing folder).
I did this creation of the user because I got a warning when I used root when I ran composer commands like composer update or composer install
The files are owned by www-data process and belong to www-data - this is for the Apache process that reads and runs the PHP files when the site is visited.
My user "web" is a member of the group www-data so that it can change/delete the files
So if my user "web" can delete the files why would composer fail?
When I use root, it works fine. But of course, I get a warning not to use root.
Can you advise, please? Is this a Drupal Composer specific issue or a general Composer issue? Thank you.
Solution for local development environment setup e.g. MacOS as host, with VM. This solution is not for the original problem, but I saw the same in my development environment and worked out a solution for that.
sudo chown -R root:0 enclosing_folder_where_you_run_vagrantup
cd enclosing_folder_where_you_run_vagrantup/files/dot/ssh/
chmod 666 *
sudo chown your_user_name *
sudo chmod -R u+rw,g+rw,o+rw enclosing_folder_where_you_run_vagrantup
then do a
vagrant provision
or
vagrant reload --provision
https://groups.google.com/d/msg/vagrant-up/qXXJ-AQuKQM/73u78JyTBQAJ
I now need to work out a solution for addressing the same issue seen on my production server (which doesn't have a MacOS host - so the above solution won't apply there)
Your files do not have the necessary permissions for the "web" user. if "web" user has the www-data group additionally than check correct permissions for group and not user.
ps. the issue is not caused by the project.
I had this problem too when I ran the php composer update command.
But, everything was solved when I ran this command as sudo, this way: sudo php composer update
Most helpful comment
I had this problem too when I ran the
php composer updatecommand.But, everything was solved when I ran this command as
sudo, this way:sudo php composer update