1

我不太明白为什么我不断收到与我的资产预编译相关的错误。从我能够从在线文档中推断出来的内容,我需要做的就是将 rake 预编译任务添加到我的 deploy.rb 文件中,确保安装了 javascript 运行时 gem,将行 load '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'
4

1 回答 1

0

尝试这个:

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

于 2012-12-03T22:44:44.297 回答