calvin-brand-light-mode
calvin-brand-dark-mode
∕
⌘K
About Calvin Podcast We Can Do This Book Speaking
aAbout Calvin
Podcast
wWe Can Do This Book
sSpeaking
Back

[Rails] Make capistrano ask for the password first

Other
Calvin Correli·Jun 7, 2006· 1 minute

I frequently find myself doing rake deploy with capistrano, and then wander off to do something else, while the checkout process runs its minute-long course. And then I forget what I was doing, and only 15 minutes later stumble upon that shell buffer again, only to discover that it’s still sitting there, waiting for my sudo password so it can restart the dispatchers.

Well, with this little snippet in my deploy.rb, it now asks for my sudo password up-front, so it’ll still be cached and valid when it really needs it at the end:

task :before_deploy, :roles => :app do
  send(run_method, "date")
end

That’s it: Force it to execute some shell command using sudo. It doesn’t matter which, so long as it doesn’t actually do anything. I chose date. Calling run_method instead of sudo directly will ensure that if you’re not using sudo, it won’t ask for your password here, either.

Previous Blinksale does ads in their interface
Next Housing inventory goes up

Comments

Write a comment...
00:00 Recording...
calvin-brand-light-mode
calvin-brand-dark-mode
1 Chestnut Hill Plaza #1139
Newark, DE 19713
United States
Copyright © 2026 Calvin Correli
powered by