Capistrano没有这样的文件加载 - 部署

时间:2022-03-07 20:37:33

When I try to run any cap commands, 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

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

I'm guessing the "deploy" is the reference to require 'deploy' from the Capfile.

我猜测“部署”是要求Capfile中的'deploy'的引用。

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不同的事情。?

6 个解决方案

#1


4  

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

#2


8  

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)会导致您提到的问题。

#3


1  

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

#4


1  

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.

按照这里的建议,我仍然有同样的问题。但是,仔细检查输出后,我注意到错误来自上限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 *的错误。将盖帽版本降级到〜> 1也是如此,错误仍然来自上限3 *。

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

通过从我的宝石套中完全移除盖子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,但仍然安装了两个上限2. * s,版本2的宝石似乎没有影响,但安装版本3. *也导致我遇到上述问题OP。

Hope this might help someone else.

希望这可能会帮助别人。

Paul

#5


1  

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,无法加载此类文件 - 部署

#6


0  

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.

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

#1


4  

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

#2


8  

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)会导致您提到的问题。

#3


1  

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

#4


1  

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.

按照这里的建议,我仍然有同样的问题。但是,仔细检查输出后,我注意到错误来自上限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 *的错误。将盖帽版本降级到〜> 1也是如此,错误仍然来自上限3 *。

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

通过从我的宝石套中完全移除盖子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,但仍然安装了两个上限2. * s,版本2的宝石似乎没有影响,但安装版本3. *也导致我遇到上述问题OP。

Hope this might help someone else.

希望这可能会帮助别人。

Paul

#5


1  

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,无法加载此类文件 - 部署

#6


0  

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.

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