getvma's avatar
Level 49

Install Composer Dependencies Fails during "Install Repository" with RuntimeException

The repository cloning process works but the installation of dependencies fails due to the following error.

[RuntimeException]                                                                              
  Could not read /home/forge/.composer/config.json                                                
  file_get_contents(/home/forge/.composer/config.json): failed to open stream: Permission denied  

The following line in the default deploy script for forge produces the error above:

composer install --no-interaction --no-dev --prefer-dist

I have to ssh into the server and run sudo composer install in order to install. It did not use to be this way. At one time the deploy script worked without any issues.

Should i change the user to forge?

0 likes
7 replies
christopher's avatar

You may try the following: Login to your forge server with ssh forge@yourip and then delete the compiled.php in storage\framework . After this try the deploy script again within forge.

getvma's avatar
Level 49

Unfortunately it appears to be more related with user rights. For example during the latest attempt it checked out the repo and even started the composer install process, but when it got to Installing the dependency noted below it received that error and halted the entire process.

[ErrorException]                                                                                                                                  
  copy(/home/forge/.composer/cache/files/maximebf/debugbar/ab12b6f57dd33b1fffa875046fd17c34d88388b9.zip): failed to open stream: Permission denied  

In my short and limited experience, this is usually related to rights, some how the web server user can no longer access root and when i sshd into the server to take a look at that directory this is what is there;

drwxrwxr-x  3 forge forge    4096 Aug 11 18:34 .
drwxr-xr-x 15 forge forge    4096 Aug 12 15:44 ..
-rw-r--r--  1 root  root  1117026 Aug 11 18:34 2015-08-10_11-58-58-cedbe7f-old.phar
-rw-------  1 forge forge      97 Jul 13 16:05 auth.json
drwxrwxr-x  4 forge forge    4096 Dec 15  2014 cache
-rw-rw-r--  1 forge forge      13 Dec 15  2014 .htaccess

Im afraid that what is going on is just way over my capacity. I started another droplet and deployed to it and there were no issues like this.

I've had this server up since the DO 1.0 version so there has been a couple of updates to forge app itself and perhaps the problem lies with an older server provisioning script that is not compatible with this newer forge version.

In the past couple of months I've had to ssh into the server and run git pulls manually. Anyway Ive started to migrate away from this droplet and will soon destroy it.

digitalformula's avatar

Did anyone ever manage to solve this issue any way other than destroying/recreating the server?

I'm running Forge against an Amazon EC2 instance - the first deployment of the first website worked without issue but then started failing. The second website won't deploy at all - same issue as the first.

It's definitely a permissions issue. Pulling from the Github repo works without issue but fails when trying to install the composer dependencies. Logging into the instance via SSH and running "composer install" also fails with access denied errors. But, running "sudo composer install" works without issues. This is the exact same result as the last response from "getvma" above i.e. doing everything manually works without issue.

I've changed nothing on this Forge-created instance other than create a couple of plain-text files in the "forge" user's home directory (they're just notes I was making along the way). The website's root directory permissions are 775, the same as they were when Forge created the site.

Forge also fails when trying to create the site's CSR - says the common name is wrong (it isn't - I've verified that).

Jmac's avatar

I was using the DigitalOcean 512MB droplet and got these strange errors, a reboot and those errors went away. Upgraded to 1GB and composer seems to run much better.

DigitalKrikits's avatar

Old post but I bumped into the same thing. The error message tells me composer doesn't have permissions to /home/$USER/.composer so I gave local user permissions to the .composer folder:

sudo chown -R $USER ~/.composer.

I later had a problem where my site folder (located at /path/to/site) permissions were set to www-data:www-data. Doing composer install gave a permission error related to a file in the vendor folder. I fixed this by doing:

sudo chown -R $USER /path/to/site/vendor.

1 like
SomeOne_'s avatar

@digitalkrikits thanks! You made my day :)

I only ran it slightly different:

sudo chown -R forge:forge and then the path.

Please or to participate in this conversation.