Deploying with Capistrano, setting development stage

Hi, I’m just starting to get to grips with using Capistrano. Watched the screencast by Scott and felt like I was understanding the thinking behind it all.

I’m developing locally on a mac using a Vagrant VM (ubuntu14,nginx,mysql). So far I’ve done the following:

At this point nothing happens and I get the message:

Stage not set, please call something such as cap production deploy, where production is a stage you have defined.

In the screencast you appear to have your ‘stage’ set as development by default, I wasn’t sure and beginning to get confused now… next I looked at config/deploy/staging.rb, and found the following line:

set :stage, :staging

So out of curiosity tried putting the following in my deploy.rb:

set :stage, :development

Once again, ran bundle exec cap development deploy:

Stage not set, please call something such as cap production deploy, where production is a stage you have defined.

That’s about as far as I got before time restraints meant I just needed to get on with my project for now. I’d really like to implement Capistrano, can anyone help me get past this? Setting the ‘Stage’ initially doesn’t seem to be mentioned in the screencast or the bedrock docs.

Another thing was confusing me which was - why does deploy.rb not have any commented out example of how to connect via ssh? Is it assumed you won’t be using ssh for your dev deploy?

If I was to deploy to my Vagrant VM, would the following lines in deploy.rb be suitable?:

server '', user: 'vagrant', roles: %w{web app db}
set :ssh_options, { keys: %w(../../puphpet/files/dot/ssh/insecure_private_key) }

(I generated my Vagrant VM with puphpet and this is the correct path to the key I believe, relative to my config/deploy.rb)

Thanks in advance to anyone who can help me get my head round this :smile:

Hey Mike

I’ve been using Capistrano for over a year and still struggle with it, so I feel your pain.

Are you trying to deploy to a local server (dev) or remote (staging or production)?

I may be wrong, but I think the file names may have something to do with this.

So when you call bundle exec cap development deploy it’s looking for a development.rb file in your deploy folder.

You can set :stage, :development in there. And then perhaps you’ll have some success.

Hope this helps

1 Like

Your solution about deploying to the VM looks correct. I’ve done that before and as long as that insecure_private_key path exists it should work.

set :stage, :staging is actually not needed anymore. Capistrano gets stage by file name. So looks like your problem is you don’t have a config/deploy/development.rb file. Since you were re-using the staging one.

Are you running the deploy native on your Mac or from your Vagrant VM? If you’re running it from the VM you need to install the correct version of Ruby there also.