1

アセットのプリコンパイルに関連するエラーが発生し続ける理由がよくわかりません。オンラインドキュメントから推測できることから、必要なのはrake precompileタスクをdeploy.rbファイルに追加し、javascriptランタイムgemがインストールされていることを確認し、line load'deploy/assets'をに追加することだけです。 capfileとcapistranoは、cap deploy:updateを実行するときに、サーバー側でアセットをプリコンパイルする必要があります。デプロイ出力に表示されるエラーメッセージの診断を誰かが手伝ってくれますか?私を助けてくれる人に事前に感謝します!よろしくお願いします!

* 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

そして、これが私のキャップファイルです:

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 に答える