0

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, 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?

Siddhant
  • 2,535
  • 4
  • 20
  • 22

1 Answers1

1

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.

Morgan
  • 4,143
  • 27
  • 35
  • But that's why I put the "pythonbrew venv use myenv" statement (similar to rvm use) after executing cd, but it still doesn't work. – Siddhant Jan 28 '13 at 14:47
  • Pastebin? unless it's in the same command, my guess is that that's not something that preserves state. – Morgan Jan 28 '13 at 18:53