Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kanchan77's avatar

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

when i am trying to install->

composer require spatie/laravel-permission

on C:>

0 likes
7 replies
neilstee's avatar

if you are using WSL try

sudo chown -R $USER  /home/<username>/.config/composer

or

sudo chown -R $USER ~/.composer/
1 like
tykus's avatar

Why are you trying to install a composer package to / at all???

onyashed's avatar
 composer update 
composer require spatie/laravel-permission 
Snapey's avatar

@onyashed why wouldn't it? It works like that for 100's of thousand times per day for developers across the world

Please or to participate in this conversation.