Composer: file_put_contents(./composer.json or ./composer.lock): failed to open stream: Permission denied

Problem

When I run Composer update in my project then I got this error.

[ErrorException]
  file_put_contents(./composer.lock): failed to open stream: Permission denied

Solution

It can be resolved with the following command:

sudo chown -R $USER ~/.composer/

That’s all.

I hope this article helps you to fix your issue.

Thanks for reading.

Keep Exploring.