gpt4 book ai didi

ruby-on-rails - Rails 4,capistrano 错误 : cannot load such file -- deploy/assets

转载 作者:行者123 更新时间:2023-12-04 04:35:33 28 4
gpt4 key购买 nike

我一直在关注这个关于部署到 VPS 的 railscast http://railscasts.com/episodes/335-deploying-to-a-vps我似乎坚持部署。当我输入 cap deploy 时,我得到了这个。

cap aborted!
cannot load such file -- deploy/assets
/files/rails/Capfile:2:in `load'
/files/rails/Capfile:2:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.0.1/lib/capistrano/application.rb:22:in `load_rakefile'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.0.1/lib/capistrano/application.rb:12:in `run'
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/capistrano-3.0.1/bin/cap:3:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/cap:23:in `load'
/usr/local/rvm/gems/ruby-2.0.0-p247/bin/cap:23:in `<main>'
(See full trace by running task with --trace)

我的部署.rb
require "bundler/capistrano"

server "(removed)", :web, :app, :db, primary: true

set :application, "Fooddiscovery"
set :user, "(removed)"
set :deploy_to, "/home/rails"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "(removed)"
set :branch, "master"

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
%w[start stop restart].each do |command|
desc "#{command} unicorn server"
task command, roles: :app, except: {no_release: true} do
run "/etc/init.d/unicorn_#{application} #{command}"
end
end

task :setup_config, roles: :app do
sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
run "mkdir -p #{shared_path}/config"
put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
puts "Now edit the config files in #{shared_path}."
end
after "deploy:setup", "deploy:setup_config"

task :symlink_config, roles: :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
end
after "deploy:finalize_update", "deploy:symlink_config"

desc "Make sure local git is in sync with remote."
task :check_revision, roles: :web do
unless `git rev-parse HEAD` == `git rev-parse origin/master`
puts "WARNING: HEAD is not the same as origin/master"
puts "Run `git push` to sync changes."
exit
end
end
before "deploy", "deploy:check_revision"
end

我的文件
load 'deploy' if respond_to?(:namespace)
load 'deploy/assets'
load 'config/deploy'

我阅读了说要添加的其他问题和答案
如果 response_to?(:namespace)
这确实有助于解决第一个错误,而不是部署/ Assets ,它用于显示仅部署的错误(无法加载此类文件 - 部署)。为所有三个链接输入 if respond_to?(:namespace) 并不能解决问题。事实上,如果我这样做了,就会出现一个新错误,告诉我未定义的局部变量或方法“tasks_without_stage_dependency”。

谢谢!

最佳答案

@Michael 正确的是,您将 Capistrano 2 语法与 Capistrano 3 一起使用,但您可以确保在 Gemfile 中使用 Capistrano 2 以进行快速修复。

gem 'capistrano', '2.15.5'

但是如果您对使用 Capistrano 3 感兴趣,这里是一个很好的 upgrade guide这对我有用。

关于ruby-on-rails - Rails 4,capistrano 错误 : cannot load such file -- deploy/assets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19803907/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com