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

PHP binary with arguments #46

Open
scuben opened this issue Aug 26, 2016 · 2 comments
Open

PHP binary with arguments #46

scuben opened this issue Aug 26, 2016 · 2 comments

Comments

@scuben
Copy link

scuben commented Aug 26, 2016

On the Task composer:install_executable which executes

task :install_executable do
    on release_roles(fetch(:composer_roles)) do
      within shared_path do
        unless test "[", "-e", "composer.phar", "]"
          composer_version = fetch(:composer_version, nil)
          composer_version_option = composer_version ? "-- --version=#{composer_version}" : ""
          execute :curl, "-s", fetch(:composer_download_url), "|", :php, composer_version_option
        end
      end
    end
  end

I need to change the php binary including its arguments.

The default commend which is being executed looks like this:
curl -s https://getcomposer.org/installer | php

What I need is:
curl -s https://getcomposer.org/installer | php56 -d allow_url_fopen=On

What I already know does not work:

  • Can't use the command_map because only the first argument of a execute statement gets resolved with the command_map
  • Can't use the workaround with fetch(:default_env).merge!(PATH: '$PATH:/usr/bin/php56 -d allow_url_fopen=On')

The only viable solution I see is the change the lib code :php to fetch(:php) (or similar) to be able to define the php binary (with its argument) with set :php, 'php -d allow_url_fopen=On'. Is this true or am I missing something?

@guillaumelecerf
Copy link
Contributor

Can't use the command_map because only the first argument of a execute statement gets resolved with the command_map

Why?

SSHKit.config.command_map[:php] = "php -d allow_url_fopen=Off" should work.

require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL

SSHKit.config.command_map[:php] = "php"

on 'localhost' do
  puts capture :php, "-i | grep allow_url_fopen"

  SSHKit.config.command_map[:php] = "php -d allow_url_fopen=Off"

  puts capture :php, "-i | grep allow_url_fopen"
end

outputs:

allow_url_fopen => On => On
allow_url_fopen => Off => Off

@fuegas
Copy link

fuegas commented Mar 16, 2017

@guillaumelecerf this does not reproduce the issue stated by @scuben. The issue is that the first argument is resolved with the command_map. The code to install composer states:

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

So only :curl gets mapped and :php does not, so overriding :php in the command_map has zero effect on the execute that pipes it to :php.

As example:

require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL

SSHKit.config.command_map[:php] = "php -d allow_url_fopen=Off"

on 'localhost' do
  puts capture :php, '-i | grep allow_url_fopen'
  puts capture :echo, '""', '|', :php, '-i | grep allow_url_fopen'
end

outputs:

allow_url_fopen => Off => Off
allow_url_fopen => On => On

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants