capistrano / sshkit

A toolkit for deploying code and assets to servers in a repeatable, testable, reliable way.
MIT License
1.16k stars 255 forks source link

command_map for piped commands #48

Open davidosomething opened 10 years ago

davidosomething commented 10 years ago

Given: The SSHKit (capistrano) command in question is: execute :curl, "-s", fetch(:composer_download_url), "|", :php

My PHP binary is in the following path and set so: SSHKit.config.command_map[:php] = '/usr/local/bin/php54'

Problem: The :curl symbol is correctly replaced from the command map, but the :php symbol is not.

I've tested replacement by changing the :curl value in the command_map and succeeded, so I'm guessing it's because :php is in a pipe or is the second substitution that it is not replaced?

leehambley commented 10 years ago

I've tested replacement by changing the :curl value in the command_map and succeeded, so I'm guessing it's because :php is in a pipe or is the second substitution that it is not replaced?

Only the first argument passed to _execute (which backs capture(), test(), execute(), etc) is mapped.

The string/symbol split is tricky, as what happens when someone would do:

execute :rake, :test

(which I often do), I want it expanded to (perhaps) /usr/bin/env rake test.

I'd consider a patch to make it map symbols regardless of their position, but you'd have to test it pretty thoroughly, and it'd mean a breaking change I think.

cibulka commented 9 years ago

Any news on this? Thank you!

leehambley commented 9 years ago

None, apparently the thread has been quiet for more than two years. What are you looking for?

cibulka commented 9 years ago

I have exactly the same problem as @davidosomething. My website is built on Wordpress and hosted on a shared host. For database import/export, I would like to use capistrano-wpcli gem.

As described on https://github.com/lavmeiker/capistrano-wpcli/issues/18, I have a problem with the following line:

execute :gunzip, "<", fetch(:wpcli_remote_db_file), "|", :wp, :db, :import, "-"

As you see, wp is not at the beginning of the command, so currently it is unaffected by setting SSHKit.config.command_map[:wp] = '~/wpcli.phar'.

Unfortunately the author of the gem is not replying to the issue and pull requests (this one would solve it), so it seems, that I'm in sort of a dead end on this. :)

Any thoughts?

jeremyzahner commented 9 years ago

@cibulka Since we got life into the repo again i guess we will most likely have a solution for this one soon.

https://github.com/lavmeiker/capistrano-wpcli/issues/18