How to use frozen Capistrano?

Background

I am on Rails 2.1 and need to freeze the Capistrano gem in my vendor folder (since my master broke his cap dependencies and I want to make myself as independent as possible).

On my local windows machine, I have installed the following environment.rb

config.gem "capistrano", :version => "2.5.2"
config.gem "net-ssh", :lib => "net/ssh", :version => "2.0.4"
config.gem "net-scp", :lib => "net/scp", :version => "1.0.1"
config.gem "net-sftp", :lib => "net/sftp", :version => "2.0.1"
config.gem "net-ssh-gateway", :lib => "net/ssh/gateway", :version => "1.0.0"

      

The gems are already set, so I froze them. Checking ...

>rake gems
...
[F] capistrano = 2.5.2
[F] net-ssh = 2.0.4
[F] net-scp = 1.0.1
[F] net-sftp = 2.0.1
[F]net-ssh-gateway = 1.0.0

      

Then I commit the local SVN repository and update it in prod Linux kernel.

Problem

When I try to run the frozen version of Capistrano, I get the following error.

$ ./vendor/gems/capistrano-2.5.2/bin/cap deploy-with-migrations 
./vendor/gems/capistrano-2.5.2/bin/cap:3:in `require': no such file to load --capistrano/cli (LoadError)
    from ./vendor/gems/capistrano-2.5.2/bin/cap:3

      

Any ideas what I did wrong?

Update

See new related question

+1


source to share


2 answers


You haven't done anything wrong. This problem occurs because the cap

pod file is capistrano/bin/cap

not designed to work offline. You will see the same result if you try to run it from your main gem folder. The executable cap

(stored in a /usr/bin/cap

standard linux installation) requires rubygems

, registers capistrano and then downloads the file capistrano/bin/cap

.

One solution for this would be to add require 'rubygems'

to your capistrano / bin / cap file:

#!/usr/bin/env ruby
require 'rubygems'
require 'capistrano/cli'
Capistrano::CLI.execute

      



If you don't want to change capistrano/bin/cap

, you can tell the rubygems library when it starts using the -r flag. Your command will look like this:

$ ruby -r rubygems ./vendor/gems/capistrano-2.5.2/bin/cap deploy-with-migrations

      

+2


source


Another way to use a specific version of Capistrano is something like adding an alias to your .bash_login like below:

alias cap1='cap _1.4.2_ '

      

where cap1 is the command you run and 1.4.2 is the version you want to run with this command and then you can:



cap1 deploy

      

will use this version of capistrano to deploy your application.

+1


source







All Articles