诊断rails app资产预编译错误

时间:2012-04-11 20:02:47

标签: ruby-on-rails deployment capistrano asset-pipeline

我无法弄清楚为什么我一直收到与资产预编译有关的错误。从我能够从在线文档中推断出来,我需要做的就是将rake预编译任务添加到我的deploy.rb文件中,确保安装了javascript运行时gems,添加行加载'deploy / assets'到当我运行cap deploy:update时,我的capfile和capistrano应该预先编译我的资产服务器端。任何人都可以帮我诊断我在部署输出中收到的错误消息吗?在此先感谢能帮助我的人!非常感谢!

* executing `deploy:assets:precompile'
  * executing "cd /usr/local/www/sites/project.example.ca/releases/20120411192244 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
    servers: ["project.example.ca"]
    [project.example.ca] executing command
    [project.example.ca] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2-p290@project' -c 'cd /usr/local/www/sites/project.example.ca/releases/20120411192244 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'
*** [err :: project.example.ca] /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby /usr/local/www/sites/project.example.ca/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: project.example.ca] 
    command finished in 30843ms
  * executing `deploy:create_symlink'
  * executing `deploy:symlink'
    triggering before callbacks for `deploy:symlink'
  * executing `assets:precompile'
  * executing "cd /usr/local/www/sites/project.example.ca/releases/20120411192244 && bundle exec rake RAILS_ENV=production assets:precompile"
    servers: ["project.example.ca"]
    [project.example.ca] executing command
    [project.example.ca] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2-p290@project' -c 'cd /usr/local/www/sites/project.example.ca/releases/20120411192244 && bundle exec rake RAILS_ENV=production assets:precompile'
*** [err :: project.example.ca] /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby /usr/local/www/sites/project.example.ca/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: project.example.ca] 
*** [err :: project.example.ca] /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby /usr/local/www/sites/project.example.ca/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: project.example.ca] 
    command finished in 45033ms
[Deprecation Warning] This API has changed, please hook `deploy:create_symlink` instead of `deploy:symlink`.
  * executing "rm -f /usr/local/www/sites/project.example.ca/current && ln -s /usr/local/www/sites/project.example.ca/releases/20120411192244 /usr/local/www/sites/project.example.ca/current"
    servers: ["project.example.ca"]
    [project.example.ca] executing command
    [project.example.ca] rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.2-p290@project' -c 'rm -f /usr/local/www/sites/project.example.ca/current && ln -s /usr/local/www/sites/project.example.ca/releases/20120411192244 /usr/local/www/sites/project.example.ca/current'
    command finished in 2968ms
 ** transaction: commit

这是我的部署文件:

$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require "rvm/capistrano"                  # Load RVM's capistrano plugin.
require "bundler/capistrano"

set :application, "Project"

set :scm, "git"
set :repository,  "ssh://git@server.example.ca/usr/local/git_root/project.git"
set :user, "deploy"

#set :rvm_bin_path, "/usr/local/rvm/bin"
set :rvm_ruby_string, "ruby-1.9.2-p290@project"
set :normalize_asset_timestamps, false

ssh_options[:forward_agent] = true

set :branch, "master"

set :deploy_via, :remote_cache

# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
set :deploy_to, "/usr/local/www/sites/project.example.ca/"

set :use_sudo, false

set :domain, 'project.example.ca'

role :app, domain
role :web, domain
role :db,  domain, :primary => true

before "deploy:symlink", "assets:precompile"

namespace :assets do
  desc "Compile assets"
  task :precompile, :roles => :app do
    run "cd #{release_path} && bundle exec rake RAILS_ENV=#{rails_env} assets:precompile"
  end
end

这是我的Capfile:

load 'deploy' if respond_to?(:namespace) # cap2 differentiator
Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy'
load 'deploy/assets'

这是我的Gemfile:

source 'http://rubygems.org'

gem 'rails', '3.1.3'

# Bundle edge Rails instead:
# gem 'rails',     :git => 'git://github.com/rails/rails.git'

gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '~> 3.0.2'
gem 'json'
gem 'yaml_db'
gem 'mysql'
gem 'rake'

group :development do
 gem 'rspec-rails', '2.6.1'
 gem 'annotate', '2.4.0'
 gem 'faker', '0.3.1'
end

group :test do
 gem 'rspec-rails', '2.6.1'
 gem 'webrat', '0.7.1'
 gem 'spork', '0.9.0.rc8'
 gem 'factory_girl_rails', '1.0'
end

# Gems used only for assets and not required
# in production environments by default
group :assets do
  gem 'execjs'
  gem 'therubyracer', :platforms => :ruby
  gem 'sass-rails',   '~> 3.1.5'
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
gem 'capistrano'

1 个答案:

答案 0 :(得分:0)

试试这个:

运行“cd#{release_path}&& bundle exec rake RAILS_ENV =#{rails_env} assets:precompile 2> / dev / null”