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

LaravelLinux

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

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.