我已经制作了一个新的Rails 3.2应用程序。当我使用Capistrano部署它时,编译资产时出错。但是资产是经过编译的,应用程序应该按照它进行部署。
在服务器上,我已经在系统范围内安装了RVM,然后创建了:
User: skolemapicture (added to group rvm)
Deploy folder: /home/skolemapicture/site
.rvmrc in /home/skolemapicture/site/.rvmrc
我的deploy.rb配置看起来像这样(省略了与问题无关的行)
set :application, "skolemapicture"
set :deploy_to , "/home/skolemapicture/site"
set :user , "skolemapicture"
set :use_sudo , false
ssh_options[:forward_agent] = true
require "bundler/capistrano"
require "rvm/capistrano"
set(:ruby_version) { '1.9.3' }
set(:rvm_ruby_string) { "#{ruby_version}@#{application}" }
set(:rvm_path) { "/usr/local/rvm" }
set(:rvm_type) { :system }
namespace :deploy do
task :precompile, :role => :app do
run "cd #{release_path}/ && bundle exec rake assets:precompile"
end
end
after "deploy:finalize_update", "deploy:precompile"
我在“cap deploy”中遇到的错误是:
* 2013-02-13 10:36:21 executing `deploy:precompile'
* executing "cd /home/skolemapicture/site/releases/20130213093619/ && bundle exec rake assets:precompile"
servers: ["web01.mapicture.com"]
[web01.mapicture.com] executing command
*** [err :: web01.mapicture.com] /usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/skolemapicture/site/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: web01.mapicture.com]
但资产是编译的。那么为什么会出现这个错误?
/ Carsten
答案 0 :(得分:2)
实际上可能是使用自定义部署成功预编译资产:预编译任务。
capistrano默认资产失败:预编译任务。
您会注意到失败的命令是
/usr/local/rvm/rubies/ruby-1.9.3-p374/bin/ruby /home/skolemapicture/site/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
不是您的自定义预编译任务:
cd #{release_path}/ && bundle exec rake assets:precompile
尝试删除deploy:precompile任务并添加
load 'deploy/assets'
到你的Capfile(如果它还没有。)
如果这不能解决,你可以发布整个Capfile和deploy.rb吗?