capistrano / composer

Capistrano extension for Composer tasks
MIT License
183 stars 48 forks source link

Override PHP Path #28

Closed zeroedin closed 9 years ago

zeroedin commented 10 years ago

I am trying to run the composer:install_executable task, however the path to php is incorrect as it is in a custom on my server and does not respond to just php for multiple version installs. is there a way to override :php in deploy.rb or deploy/environment.rb?

I've tried neither work:

SSHKit.config.command_map[:php] = '/path/to/php/bin/php'
set :php, '/path/to/php/bin/php'

Line 17 composer.rake

execute :curl, "-s", fetch(:composer_download_url), "|", :php, composer_version_option

Should :php possibly be fetch(:php) much like the :composer_download_url?

Or am I just doing it wrong?

swalkinshaw commented 10 years ago

fetch is only for variables set with set.

Overriding it in the command map should be what you want. However I'm wondering if since :php isn't the first argument under execute that it isn't retrieved from the command map.

In which case I'm not exactly sure what the solution without searching yet.

swalkinshaw commented 9 years ago

SSHKit/Capistrano only looks up the first argument to execute in the command map which explains this behaviour. What you can do update your PATH env variable in the stage config. Something like this:

fetch(:default_env).merge!(PATH: '$PATH:/path/to/php5')
rob-gordon commented 8 years ago

I'm attempting this now, hoping to get capistrano working on my shared hosting environment.

The last line of my deploy/staging.rb looks like:

fetch(:default_env).merge!(PATH: '$PATH:/usr/bin/php5.5-cli')

Even though it registers (at least it displays in the output of cap staging deploy ) it's still trying to run composer.phar install with an outdated version of php. I've already tried aliasing php in _bashprofile and bashrc, which is what brought me here. Am I missing something?

INFO[61605541] Running /kunden/homepages/23/d356879201/htdocs/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader on siagroup.winnowspace.com
DEBUG[61605541] Command: cd ~/winnowspace/dev/thewinefeed/site/releases/20160404174350 && ( WP_ENV=staging PATH=$PATH:/usr/bin/php5.5-cli /kunden/homepages/23/d356879201/htdocs/composer.phar install --no-dev --prefer-dist --no-interaction --quiet --optimize-autoloader )
DEBUG[61605541]     X-Powered-By: PHP/4.4.9
DEBUG[61605541]     Content-type: text/html
DEBUG[61605541]
DEBUG[61605541]     <br />
DEBUG[61605541]     <b>Parse error</b>:  syntax error, unexpected T_STRING in <b>/homepages/23/d356879201/htdocs/composer.phar</b> on line <b>90</b><br />
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host siagroup.winnowspace.com: composer exit status: 255
composer stdout: Nothing written
composer stderr: Nothing written
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in `exit_status='
/Library/Ruby/Gems/2.0.0/gems/sshkit-1.5.1/lib/sshkit/backends/netssh.rb:148:in `block (5 levels) in _execute'
rob-gordon commented 8 years ago

Ah, didn't realize I could include the version of php in the composer variable. These settings (from here) fixed it...

SSHKit.config.command_map[:bash] = "/bin/bash"
SSHKit.config.command_map[:composer] = "/usr/bin/php5.5-cli /home2/path/to/composer.phar"
brtsos commented 7 years ago

@rob-gordon That's work! Thank you!