Why does Capistrano need modifications to use something like pythonbrew?
Question: As I understand, all that Capistrano does is ssh into the server and execute
the commands we want it to (mostly).

I've used rvm in some past couple of projects, and had to install the rvm-
capistrano gem. Otherwise, it failed to find the executables (or so I recall),
even though we had a proper .rvmrc file (with the correct ruby and the correct
gemset) in the repository.

Similarly, today I was setting up deployment for a project for which I'm using
pythonbrew (yeah I know I could use fabric, but that's not important for this
question), and a simple "cd #{deploy_to}/current && pythonbrew venv use myenv
&& gunicorn_django -c gunicorn.py" gave me an error message saying "cannot
find the executable gunicorn_django". This, I suppose is because the
virtualenv was not activated correctly. But didn't we activate the environment
when we did "pythonbrew venv use myenv"? The complete command works fine if I
ssh into the server and execute it on the shell, but it doesn't when I do it
via Capistrano.

My question is - why does Capistrano need modifications to play along with
programs like rvm and pythonbrew, even though all it's doing is executing a
couple of commands over ssh?


Answer: Thats because their ssh'ing in doesn't activate your shell's environment. So
it's not picking up the source statements that enable the magic. Just do an
rvm use ... before running commands instead of assuming the cd will pick that
up automatically. Should be fine then. If you had been using fabric there is
the env() context manager that you could use to be sure thats run before each
command.

