sudo composer install vs. composer install

Solution 1:

Delete your vendor directory and run composer install again.

You're getting the permission denied error because the vendor/composer/installed.json file was created by the root user when you ran sudo composer install, so now when you run composer install your user doesn't have permission to edit that file.

Update:

If you are working within a live document root (you shouldn't be - read up on atomic deployment) then you can try chown on the vendor directory and its contents to avoid any downtime between the deletion and re-running composer install:

$ sudo chown -R myuser: vendor/

Replace myuser with your username.