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

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

Merged
merged 1 commit into from
Jun 11, 2014

Conversation

Aupajo
Copy link
Contributor

@Aupajo Aupajo commented Jun 11, 2014

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
Copy link
Contributor Author

Aupajo commented Jun 11, 2014

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
Copy link
Contributor Author

Aupajo commented Jun 11, 2014

Yep, this works nicely! Now I can run:

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

kirs added a commit that referenced this pull request Jun 11, 2014
Issue with Capistrano calling shell script that depends on Ruby
@kirs kirs merged commit bf9f0e2 into capistrano:master Jun 11, 2014
@kirs
Copy link
Member

kirs commented Jun 11, 2014

Thanks!

@Aupajo
Copy link
Contributor Author

Aupajo commented Jun 16, 2014

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

@kirs
Copy link
Member

kirs commented Jun 21, 2014

Done!

@Aupajo
Copy link
Contributor Author

Aupajo commented Jun 22, 2014

🎉

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

Successfully merging this pull request may close these issues.

None yet

2 participants