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

LaravelLinux

MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

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/Code language: JavaScript (javascript)

That’s all.

I hope this article helps you to fix your issue.

Thanks for reading.

Keep Exploring.