Running rbenv from capistrano #446

realleoman opened this Issue Sep 11, 2013 · 2 comments


None yet
2 participants


I'm performing some capistrano tasks and when I try to perform the following one from my computer

desc "Run the rbenv to check Rbenv version"
task :rbenv_version do
run "cd #{current_path} && rbenv version"

I've got the following message=>

$ cap devel_server deploy:ruby_version
** [out ::] sh: rbenv: command not found

but if I run it from command line , I get the version correctly

rbenv version
1.9.3-p448 (set by //.rbenv/version)

How can I pass the correct PATH in capistrano so I can perform all the tasks I need to execute from my terminal?



mislav commented Sep 11, 2013

When you execute a command with Capistrano, on the server it's executed in a non-interactive, non-login bash shell (assuming bash is the default shell for the deploy user). Unfortunately, that means that neither .bashrc nor .bash_profile will get sourced like they would if you log in with ssh interactively and execute rbenv version from there.

You can try using Capistrano options to set the PATH environment variable. For instance:

set :default_environment, {
  'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH",

In any case, the goal is to edit your PATH to include both rbenv's bin directory and shims.

mislav closed this Sep 11, 2013

Thanks mislav... That pretty piece of code made it work!!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment