capistrano / chruby

http://capistranorb.com/
MIT License
23 stars 10 forks source link

Issue with Capistrano calling shell script that depends on Ruby #6

Closed Aupajo closed 10 years ago

Aupajo commented 10 years ago

Chruby works great, but I'm having an issue when trying to use Ruby in a shell script that Capistrano calls:

#!/usr/bin/env sh
# ...snip...
ruby --something
# ...snip...

It runs in a Capistrano task like this:

task :that_calls_shell_script do
    on roles(:app) do
      within release_path do
          execute "path/to/shell/script"
      end
    end
  end

The problem is, if I understand correctly, that Capistrano Chruby only seems to call Chruby through chruby-exec, which is nice and self-contained, but a problem when you need the Chruby environment there for other purposes.

Is there some kind of workaround?

Aupajo commented 10 years ago

Possibly one way of addressing this would be to expose chruby_prefix (as defined in the map_bins task). I could then run something like:

execute :chruby_prefix, "path/to/shell/script"

Or even if it was available to fetch, at a pinch:

execute "#{fetch(:chruby_prefix} path/to/shell/script"
Aupajo commented 10 years ago

Yep, this works nicely! Now I can run:

execute :chruby_prefix, "path/to/shell/script"
kirs commented 10 years ago

Thanks!

Aupajo commented 10 years ago

Thanks for merging! Any chance of a gem release? :)

kirs commented 10 years ago

Done!

Aupajo commented 10 years ago

:tada: