Ruby-on-rails Capistrano 没有要加载的此类文件 -- 部署

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9370920/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:51:53  来源:igfitidea点击:

Capistrano no such file to load -- deploy

ruby-on-railscapistrano

提问by Tyler DeWitt

When I try to run any capcommands, I get a "no such file to load -- deploy" error.

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

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:

这是 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

配置/部署.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.

我猜“部署”是require 'deploy'来自 Capfile的引用。

What did I mess up?

我搞砸了什么?

Thanks

谢谢

Edit

编辑

Changing the first line of the Capfile to

将 Capfile 的第一行更改为

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 .?

作品。知道为什么默认情况下 Capfile 带有这条“断”行吗?我需要做一些不同的事情capify .吗?

采纳答案by Michael Shimmins

Try:

尝试:

load 'deploy'

(Assuming you're using capistrano 2).

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

Our capfile looks like this:

我们的 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

回答by Tsutomu

Downgrade your capistrano to the previous version 2.9.0.

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

The newest one (2.11.0) causes the problem you mentioned.

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

回答by Jesse Wolgamott

Here's my Capfile -- try it since you're on capistrano 2

这是我的 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

回答by paul h

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.* .

问题是由于未指定 cap gem 版本并运行 bundle update 导致的,这将 cap 更新为 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.

按照这里的建议之后,我仍然遇到同样的问题。但是,在仔细检查输出后,我注意到错误来自 cap 3.* 无法加载部署。

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.* .

这很奇怪,因为我随后将 cap gem 版本设置为 ~> 2,仍然有来自 cap 3.* 的错误。用同样的方法将 cap 版本降级到 ~> 1,并且错误仍然来自 cap 3.* 。

It was fixed by removing cap 3.* from my gemset completely.

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

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.

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

Hope this might help someone else.

希望这可以帮助别人。

Paul

保罗

回答by Meli

I had this problem today, it was due to me having capistrano 3.* installed and this thread provided the solution that worked for me:

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

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

Rails 4, Capistrano 3.0.0, 无法加载此类文件 -- deploy

回答by daveomcd

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...

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

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.

因此,在完成 bundle install 后,请尝试使用命令cap install STAGES=sandbox,qa,production或您需要的任何阶段。之后它应该覆盖你的文件。去编辑它添加的文件,你应该很高兴。