我如何使用冷冻Capistrano? [英] How do I use frozen Capistrano?

查看:98
本文介绍了我如何使用冷冻Capistrano?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Backstory



我在Rails 2.1上,需要将Capistrano gem冻结到我的供应商文件夹中(因为我的主机已经打破了它们的上限gem依赖关系,让我自己尽可能独立)。



在我本地的Windows机器上,我放置了以下我的environment.rb

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

宝石已经安装完毕,所以我冻结了它们。检查...

 >耙宝石
...
[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

然后我在本地提交SVN并在prod Linux上更新。

问题



当我尝试运行我的Capistrano冻结版本时,出现以下错误。 / p>

  $ ./vendor/gems/capistrano-2.5.2/bin/cap deploy-with-migrations 
./ vendor / gems / capistrano-2.5.2 / bin / cap:3:在`require'中:不需要这样的文件来加载--capistrano / cli(LoadError)
from ./vendor/gems/capistrano-2.5.2 / bin / cap:3

任何想法我做错了?



更新



查看新的相关问题

解决方案

你没有做错任何事情。您看到这个问题是因为 capistrano / bin / cap 下的 cap 文件并不打算作为一个独立的。如果您尝试从主宝石文件夹运行它,您会看到相同的结果。 cap 可执行文件(在标准linux安装中存储在 / usr / bin / cap )需要 ruby​​gems ,注册capistrano和,然后加载 capistrano / bin / cap 文件。



解决这个问题的方法是在你的capistrano / bin / cap文件中添加 require'rubygems'

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

如果您不想修改 capistrano / bin / cap 当您使用-r标志运行它时,可以特别包含rubygems库。您给定的命令如下所示:

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


Backstory

I'm on Rails 2.1 and need to freeze the Capistrano gem to my vendor folder (as my host has broken their cap gem dependencies and I want to make myself as independent as possible).

On my local windows machine I've put the following my 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 were already installed and 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

I then commit to SVN locally and update on the prod Linux box.

Problem

When I try and run my 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've done wrong?

Update

See new related question

解决方案

You haven't done anything wrong. You're seeing this issue because the cap file under capistrano/bin/cap isn't meant to be run as a stand-alone. You'll see the same result if you try to run it from your primary gem folder. The cap executable (stored at /usr/bin/cap on a standard linux install) requires rubygems, registers capistrano and then loads the capistrano/bin/cap file.

One solution to 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 modify capistrano/bin/cap you could specifically include the rubygems library when you run it using the -r flag. Your given command would look like this:

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

这篇关于我如何使用冷冻Capistrano?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆