I tried the installation on another server just to make sure it wasn't an environment issue, and now I'm running into this:
Uncaught Exception: [RuntimeException] The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly
Which is triggered by submitting a package. Any ideas?
are you running your webserver with a user who does not have a HOME ?
Anyway, this is a deployment issue IMO
The user does indeed have a home. I don't dispute it might be a deployment issue. I'm just not sure where else to turn - it seems to be isolated to the web interface of package submission.
I just tried installing it on a third server, completely different stack - and have the same error upon trying to submit a package. I've tried manually setting the environment variables. I'm not sure what's happening here.

Most likely your www-data user has no HOME environment var set up, or the web server/php workers are started in a sandboxed environment that has no HOME env var. Try running a var_dump($_SERVER) in a php script through the web server to verify, but if it says that I'm pretty sure the HOME env var is missing.
Both you and Stof were right. After I did a little more digging, the php user didn't have a home set. I ended up setting it manually with an auto_prepend_file. Thanks!
For anyone that finds themselves here by Google, this is what I did:
The php user didn't have HOME or COMPOSER_HOME set, so I created a php.ini file in my web root with the following contents:
auto_prepend_file = /home/yourusername/directory/set_environment.php
I then created a set_environment.php file in the same directory, and set my COMPOSER_HOME directory.
Now, whenever the app is run, the COMPOSER_HOME environment variable will be set.
Hope this helps!
@etcook If you are using PHP-FPM, there is a much cleaner way to set the environment variable to the process:
; php-fpm.conf
env[COMPOSER_HOME]= /home/etc/webapps/novuspackagist/.composer
@etcook i got the same error message when performing a post-commit subversion svn script which shall run the composer install command within one of my vagrant virtual machines. i figured out its an enviroment variable issue, where a running linux script does not have those set.
the solution was to manually define all neccessary variables in the script, such as (i did a brute force with definition, dont know which ones actually the composer needs) (i also still have there some variables not exported, obviously composer doesnt need them and i was lazy to delete them, i simply copy-pasted the output of printenv):
XDG_SESSION_ID=2; export XDG_SESSION_ID
SHELL=/bin/bash; export SHELL
TERM=xterm;export TERM
OLDPWD=/home/svn/Beautyportal;export OLDPWD
USER=vagrant;export USER
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:;export LS_COLORS
SUDO_USER=vagrant;export SUDO_USER
SUDO_UID=1000
USERNAME=root
MAIL=/var/mail/vagrant
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games;export PATH
PWD=/home/vagrant;export PWD
LANG=en_US.UTF-8;export LANG
SHLVL=1
SUDO_COMMAND=/bin/su vagrant
HOME=/home/vagrant;export HOME
LOGNAME=vagrant
LESSOPEN=| /usr/bin/lesspipe %s
XDG_RUNTIME_DIR=/run/user/1000
SUDO_GID=1000
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/printenv
I just edit /etc/profile锛宎nd append export HOME=~, then I exec $ source /etc/profile.
If the system which Packagist is set-up on, runs the webserver with a user without a home directory, the simplest (and most effective) way to correct the missing environment variable issue is to add it to the server configuration.
_@stof's suggestion of adding the environment value to php-fpm.conf didn't seem to work._
If the webserver is Apache, you can add the environment variable directly in the vHost/configuration file or (if AllowOverride is set to allow it) in the Access file (ex: .htaccess); make sure Apache's env module is loaded.
<VirtualHost addr:*>
...
SetEnv COMPOSER_HOME "/path/to/use/for/composer/home"
...
</VirtualHost>
.htaccess)SetEnv COMPOSER_HOME "/path/to/use/for/composer/home"
If the webserver is NGINX, you'll need to add it to the server configuration.
server {
...
location ~ \.php$ {
...
fastcgi_param COMPOSER_HOME "/path/to/use/for/composer/home";
include fastcgi_params;
}
}
Make sure to restart the webserver after making modifications to the configurations (not required if changing the Access file).
Best of luck!
I ran into this issue while working on some really old Puppet code. The manifest file was installing Composer like this:
exec {
'composer install':
command => 'curl -sS https://getcomposer.org/installer | php',
path => '/usr/bin:/usr/local/bin:/usr/sbin:/sbin',
creates => '/usr/local/bin/composer.phar',
cwd => '/usr/local/bin',
require => [ Package[ 'curl' ], Class [ 'php::mod_php5' ] ],
}
To fix it, I brought in a composer package from puppetforge (https://forge.puppet.com/willdurand/composer is the one I used) and installed it via:
class { '::composer':
command_name => 'composer',
target_dir => '/usr/local/bin',
require => [ Package[ 'curl' ], Class [ 'php::mod_php5' ] ],
}
@samlikins and what is "/path/to/use/for/composer/home" ???
Is it the web folder? example: "/var/www/html/myweb" ??
Thanks
@crismablanco
It's been some time since I posted, and can't recall my thought process at the time. I however have reviewed the issue again, and from what I can tell the COMPOSER_HOME environment variable should be pointing to the directory which has the composer configuration files in it (ex: .composer). Make sure you aren't pointing to a file, but that the path is to the directory.
Most helpful comment
For anyone that finds themselves here by Google, this is what I did:
The php user didn't have HOME or COMPOSER_HOME set, so I created a php.ini file in my web root with the following contents:
auto_prepend_file = /home/yourusername/directory/set_environment.php
I then created a set_environment.php file in the same directory, and set my COMPOSER_HOME directory.
Now, whenever the app is run, the COMPOSER_HOME environment variable will be set.
Hope this helps!