Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override PHP Path #28

Closed
zeroedin opened this issue Sep 4, 2014 · 5 comments

Comments

Projects
None yet
4 participants
@zeroedin
Copy link

commented Sep 4, 2014

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

This comment has been minimized.

Copy link
Member

commented Sep 4, 2014

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

This comment has been minimized.

Copy link
Member

commented Nov 15, 2014

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

This comment has been minimized.

Copy link

commented Apr 4, 2016

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 bash_profile 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

This comment has been minimized.

Copy link

commented Apr 4, 2016

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

This comment has been minimized.

Copy link

commented May 2, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.