successful install of composer, but message shows: The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly

12,737

The following worked for me, successfully allowing me to see the composer output:

export COMPOSER_HOME="$HOME/.config/composer";
composer

Note that I was able to just run composer in the project folder, didn't need to use the full path.

REFERENCE: https://github.com/consolidation/cgr/issues/10

(javi-dev commented on Feb 24)

Share:
12,737
Oliver Williams
Author by

Oliver Williams

Updated on July 23, 2022

Comments

  • Oliver Williams
    Oliver Williams almost 2 years

    I have installed composer on a Ubuntu vagrant box, running php 7.0 (which was just installed prior to this). Trying simply composer, or the full path php /usr/local/bin/composer both result in the following error:

    The HOME or COMPOSER_HOME environment variable must be set for 
    composer to run correctly
    

    I am unfamiliar with which env variable to set (or both), what value it should be set to, or where it should be set/declared! I've searched quite a few forums including github, but I'm not seeing this information. Appreciate your help.

    error after composer install

    UPDATE: Also tried this, same message:

    curl -sS https://getcomposer.org/installer | php
    
  • Jitesh Meniya
    Jitesh Meniya almost 5 years
    Thanks, don't know where were from you guys get these solutions. :)
  • TomTerrific
    TomTerrific over 2 years
    Where do these lines go? I'm trying to run the composer installer php script, and I get the same message because neither HOME nor COMPOSER_HOME is set in the environment. This "solution" defines what COMPOSER_HOME should contain, assuming we can guess what $HOME is, but where is this normally set? Do we add a setenv statement at the top of every composer script? Is it set in the PHP configuration? I know these things are possible, but what is normal/best practice?