Capistrano 没有要加载的文件 -- 部署
当我尝试运行任何 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://[email protected]/~/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
我猜测“deploy”是 Capfile 中对 require 'deploy'
的引用。
我搞砸了什么?
谢谢
编辑
更改 Capfile 的第一行以使其
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
有效。知道为什么 Capfile 默认情况下会带有这条“断线”吗?我需要做一些与 capify .
不同的事情吗?
When I try to run any cap
commands, I get a "no such file to load -- deploy" error.
Here is the output:
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>'
Here is the 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://[email protected]/~/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
I'm guessing the "deploy" is the reference to require 'deploy'
from the Capfile.
What did I mess up?
Thanks
Edit
Changing the first line of the Capfile to
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
works. Any idea why the Capfile ships by default with this "broken" line in it? Do I need to do something different than capify .
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
将您的 capistrano 降级到之前的版本 2.9.0。
最新的(2.11.0)会导致您提到的问题。
Downgrade your capistrano to the previous version 2.9.0.
The newest one (2.11.0) causes the problem you mentioned.
尝试:(
假设您使用的是 capistrano 2)。
我们的 capfile 看起来像这样:
Try:
(Assuming you're using capistrano 2).
Our capfile looks like this:
这是我的 Capfile - 既然您使用的是 capistrano 2,请尝试一下
Here's my Capfile -- try it since you're on capistrano 2
我今天刚刚遇到这个问题。
该问题是由于未指定 cap gem 版本并运行捆绑包更新而导致的,该更新将 cap 更新为 3.* 。
按照这里的建议后,我仍然遇到同样的问题。然而,仔细检查输出后,我注意到错误来自 cap 3.* 无法加载部署。
这很奇怪,因为我随后将 cap gem 版本设置为 ~> 2,仍然有来自 cap 3.* 的错误。执行相同的操作将上限版本降级为 ~> 1,错误仍然来自 cap 3.* 。
通过从我的宝石集中完全删除 cap 3.* 来修复它。
我的印象是我可以安装多个 gem 版本,只要在 Gemfile 中指定了我想要使用的版本,那么这就是使用的版本。尽管我的 Gemfile 指定 ~> 我仍然安装了几个 cap 2.* 。 1,版本 2 gems 似乎没有影响,但是也安装了版本 3.*,导致我遇到了 OP 上面描述的问题。
希望这可以帮助别人。
保罗
I've just had this problem today.
The problem was caused by not specifying the cap gem version, and running bundle update, which updated cap to 3.* .
After following the advice here, I still had the same problem. However, after checking the output carefully, I noticed that the error was coming from cap 3.* not being able to load deploy.
This was strange, because I had then set the cap gem version to ~> 2, still had the error coming from cap 3.* . Did the same to downgrade the cap version to ~> 1, and again the error was still coming from cap 3.* .
It was fixed by removing cap 3.* from my gemset completely.
I was under the impression that I could have multiple gem versions installed, and as long as the version I wanted to use was specified in the Gemfile, then that would be the version used. I still have a couple of cap 2.* s installed although my Gemfile specifies ~> 1, the version 2 gems don't seem to impact, but having version 3.* installed too, causes me to have the problem described above by the OP.
Hope this might help someone else.
Paul
我今天遇到了这个问题,这是因为我安装了 capistrano 3.* 并且该线程提供了适合我的解决方案:
Rails 4,卡皮斯特拉诺3.0.0,无法加载此类文件--部署
I had this problem today, it was due to me having capistrano 3.* installed and this thread provided the solution that worked for me:
Rails 4, Capistrano 3.0.0, cannot load such file -- deploy
所以我遇到了同样的错误。我的错误是在安装 gem 文件后,我跳过了安装步骤,而是使用旧的 2.x 版本示例作为我的 Capfile 和部署文件...
因此,在进行捆绑安装后,尝试使用命令
cap install STAGES=sandbox 、质量保证、生产
,或您需要的任何阶段。之后它应该会覆盖您的文件。去编辑它添加的文件,你就可以开始了。So I ran into this same error. My mistake was is after installing the gem files I skipped the install steps and instead had used old 2.x version examples for my Capfile and deploy files...
So after doing bundle install try using the command
cap install STAGES=sandbox,qa,production
, or whichever stages you need. After that it should overwrite your files. Go edit the files it added and you should be good to go.