Question

At the end of my vagrant provisioning script I attempt to install composer using the following :

sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

However when this is executed I get the following errors :

SlowTimer [5612ms] at curl: https://getcomposer.org/composer.phar
Download failed: Failed to open https://getcomposer.org/composer.phar (Resolving timed out after 5613 milliseconds)
The download failed repeatedly, aborting.

If I have php installed rather than hhvm and run the same commands on my vagrant vm the install is successful which indicates an incompatibility in hhvm. However I also have a Linode running Ubuntu 14.04 and hhvm (no php) and can install composer using these commands without any problems.

Given I can install composer using a similar environment on my Linode why does it fail on my vagrant vm and how do I rectify this?

Was it helpful?

Solution

As a work around until this gets fixed in vagrant, hhvm or where ever the root cause exisits you can download the composer installer using wget:

sudo wget https://getcomposer.org/installer

Then install composer using hhvm with some options to extend the timeouts as recommended here.

hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 installer

Then install composer globally as usual and clean up :

sudo mv composer.phar /usr/local/bin/composer
sudo rm installer

OTHER TIPS

the steps from composer.org

  1. $ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  2. $ php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" notes hash changes every version of composer
  3. $ sudo apt-get install curl php-cli php-mbstring git unzip
  4. $ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

you have installed composer globally now, to verify just use the following command: $ composer -V

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top