3

When I run 'composer update' I get this error:

Writing lock file
Generating autoload files


  [ErrorException]                  
  chmod(): Operation not permitted  

*It works just fine with sudo, but then I have to reset the owner & permissions, Which is really annoying...
**I also tried to reset the owner of ~/.composer to www-data with 777, no effect.
***I'm using Ubuntu 16.04 LTS + Apache/2.4.18 & php7.0.26


Any idea?

1 Answer 1

9

chmod will only work without sudo if the owner of the file is the same as the one running the composer update command.

The problem is that the error message doesn't tell you which file it's trying to chmod.

This depends on the project.

Running the command in verbose mode will give you more details:

composer update -v

In my case, it gave me a stack trace, showing which file called chmod(), and the line number.
However, it didn't give me the path of the file passed to chmod().
I had to add a simple echo right before the call to chmod() (without forgetting to remove it afterwards).

Once you know which file/folder is responsible for the error message, change its owner with chown.

In my case (Magento 2.3), the culprit was the bin/magento file, which needs to be owned by the user running the composer commands.

1
  • 1
    Changing bin/magento owner helped
    – srokatonie
    Commented Feb 9, 2020 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.