【问题标题】:Capistrano no such file to load -- deployCapistrano 没有要加载的文件——部署
【发布时间】:2012-03-11 08:55:00
【问题描述】:

当我尝试运行任何 cap 命令时,我收到“没有要加载的此类文件 -- 部署”错误。

这是输出:

Tylers-MacBook-Pro:cap_app Tyler$ cap -T
/Users/Tyler/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- deploy (LoadError)
from /Users/Tyler/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:152:in `require'
from Capfile:1:in `load'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:93:in `instance_eval'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:93:in `load'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:172:in `load_from_file'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:89:in `load'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:86:in `block in load'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:86:in `each'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/configuration/loading.rb:86:in `load'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/cli/execute.rb:65:in `block in load_recipes'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/cli/execute.rb:65:in `each'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/cli/execute.rb:65:in `load_recipes'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/cli/execute.rb:31:in `execute!'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/lib/capistrano/cli/execute.rb:14:in `execute'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/gems/capistrano-2.11.0/bin/cap:4:in `<top (required)>'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/bin/cap:19:in `load'
from /Users/Tyler/.rvm/gems/ruby-1.9.2-p290/bin/cap:19:in `<main>'

这是 Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'
gem 'capistrano'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
#   gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

config/deploy.rb

require 'bundler/capistrano'
set :application, "CapistranoApp" 
set :repository,  "ssh://ubuntu@weaponxo.com/~/projectdir.git"
set :applicationdir, "/var/www/#{application}"
set :domain, "ror.weaponxo.com"


set :scm, :git
set :branch, "master"
set :git_shallow_clone, 1
set :scm_verbose, true
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`

role :web, domain                          # Your HTTP server, Apache/etc
role :app, domain                          # This may be the same as your `Web` server
role :db,  domain, :primary => true # This is where Rails migrations will run

set :deploy_to, applicationdir
set :deploy_via, :remote_cache

# if you're still using the script/reaper helper you will need
# these http://github.com/rails/irs_process_scripts

# If you are using Passenger mod_rails uncomment this:
 namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
  end

Capfile:

require 'deploy'
# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks

我猜“部署”是 Capfile 中对 require 'deploy' 的引用。

我搞砸了什么?

谢谢

编辑

将 Capfile 的第一行改为

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

有效。知道为什么 Capfile 默认附带这个“断”行吗?我需要做与capify . 不同的事情吗?

【问题讨论】:

  • 这也发生在 capistrano v3 上。默认的 Capfile 似乎已损坏。

标签: ruby-on-rails capistrano


【解决方案1】:

将您的 capistrano 降级到之前的 2.9.0 版本。

最新的(2.11.0)导致您提到的问题。

【讨论】:

  • Capistrano 2.11.2 似乎还可以。
  • 我从 3 降级到 2.15.5 b/c,它在我当前的代码中根本不起作用。不知道为什么会这样。你应该在你的 gemfile 中指定版本,这样你就知道你会得到什么。我所做的只是为其他东西运行捆绑更新,它也更新了上限。有点烦人。
【解决方案2】:

试试:

load 'deploy'

(假设您使用的是 capistrano 2)。

我们的 capfile 如下所示:

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'

Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks

【讨论】:

  • 谢谢 - 知道为什么默认 Capfile 会损坏吗?
【解决方案3】:

这是我的 Capfile - 试试吧,因为你在 capistrano 2 上

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

# Uncomment if you are using Rails' asset pipeline
# load 'deploy/assets'

Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks

【讨论】:

  • 谢谢 - 知道为什么默认 Capfile 会损坏吗?
【解决方案4】:

我今天刚遇到这个问题。

问题是由于未指定 cap gem 版本,并运行 bundle update,将 cap 更新为 3.* 造成的。

按照这里的建议后,我仍然遇到同样的问题。但是,在仔细检查输出后,我注意到错误来自 cap 3.* not able to load deploy。

这很奇怪,因为我将 cap gem 版本设置为 ~> 2,仍然有来自 cap 3.* 的错误。将 cap 版本降级到 ~> 1 也是如此,错误仍然来自 cap 3.*。

通过从我的 gemset 中完全移除 cap 3.* 来修复它。

我的印象是我可以安装多个 gem 版本,只要在 Gemfile 中指定了我要使用的版本,那就是使用的版本。尽管我的 Gemfile 指定了 ~> 1,但我仍然安装了几个 cap 2.*,版本 2 gem 似乎没有影响,但是也安装了版本 3.*,导致我遇到上述问题OP。

希望这可能对其他人有所帮助。

保罗

【讨论】:

  • 想提出一个新问题并发布您的 gemfile?比我更了解 bundler 的人可能会有一个想法。很好的解决方法
  • 我安装了多个版本capistrano (3.1.0, 2.15.5, 2.14.2),但没有在我的 Gemfile 中指定版本,它正在创建与问题中相同的错误。一旦我在 Gemfile gem 'capistrano', '~&gt; 2.15.5' 中指定了版本,我就可以做一个bundle exec cap deploy
【解决方案5】:

我今天遇到了这个问题,这是由于我安装了 capistrano 3.* 而这个线程提供了对我有用的解决方案:

Rails 4, Capistrano 3.0.0, cannot load such file -- deploy

【讨论】:

    【解决方案6】:

    所以我遇到了同样的错误。我的错误是在安装 gem 文件后我跳过了安装步骤,而是使用了旧的 2.x 版本示例作为我的 Capfile 和部署文件......

    因此,在进行捆绑安装后,请尝试使用命令cap install STAGES=sandbox,qa,production,或您需要的任何阶段。之后,它应该覆盖您的文件。去编辑它添加的文件,你应该很好去。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      相关资源
      最近更新 更多