Composer error on staging deployment

Hej guys,

cap staging deploy:check

works without any errors - but when i just deploy with cap staging deploy i get an error with composer.
Ive installed composer phar file in the /shared folder - is that right?

DEBUG [f4d8ab58] Command: cd /var/www/html/releases/20150423112136 && ( WP_ENV=staging /usr/bin/env composer install --no-dev --no-interaction --optimize-autoloader )
DEBUG [f4d8ab58] 	/usr/bin/env: 
DEBUG [f4d8ab58] 	composer
DEBUG [f4d8ab58] 	: No such file or directory
DEBUG [f4d8ab58] 	
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as nodeuser@188.166.30.187: composer exit status: 127
composer stdout: Nothing written
composer stderr: /usr/bin/env: composer: No such file or directory

Ive set: set :composer_install_flags, '--no-dev --no-interaction --optimize-autoloader' but it doesnt seem to give me any extra composer debugging.

Hm!

SSHKit.config.command_map[:composer] = "php /var/www/html/shared/composer.phar"
SSHKit.config.command_map[:composer] = 'php -d memory_limit=1G /var/www/html/shared/composer.phar'

Seems to do the trick…

1 Like

Did you bundle install?

Capistrano-composer should take care of this for you

Yes did run bundle install - but it works efter settings composer.phar path and memory limit…

Thanks for posting your fix.

Just a note that cap staging deploy:check only checks permissions/folders. An extension like capistrano-composer can’t hook into it to say “also check if composer bin exists” unfortunately.

@swalkinshaw I had just messed up creating composer global on the server. Works fine now.
But if you have time, can you tell me why you think i dont get any errors running cap staging wpcli:db:push while the db doesnt get updated? (it does say ‘mysqldump: command not found’ in the beginning of the deploy but everything else seem to run fine)

Never used that plugin so I can’t be of much help. But I’m guessing that mysqldump error is the problem even if it may seem to run fine.

1 Like

Hi everyone! I found the solution. Check it here:

Thanks, this worked for me. Could be useful to some to specify where to add these settings (if they’re not that familiar with Ruby / capistrano, like me): add these lines to either deploy.rb, staging.rb or production.rb, depending on whether staging and production share the same host or paths.