5

Rails 3.2.6アプリを本番環境にデプロイしようとして少し問題が発生しています。デプロイは、アセットをプリコンパイルするまではうまくいくようです。ここに表示されるエラーは次のとおりです。

command finished in 1740ms
  * executing "cd /home/deployer/apps/stealthygecko/releases/20120717222341 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"
servers: ["xx.xxx.xxx.xxx"]
[xx.xxx.xxx.xxx] executing command
 ** [out :: xx.xxx.xxx.xxx] rake aborted!
 ** [out :: xx.xxx.xxx.xxx] no such file to load -- addressable/uri
 ** [out :: xx.xxx.xxx.xxx] 
 ** [out :: xx.xxx.xxx.xxx] (See full trace by running task with --trace)
command finished in 3131ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deployer/apps/stealthygecko/releases/20120717222341; true"
servers: ["xx.xxx.xxx.xxx"]
[xx.xxx.xxx.xxx] executing command
command finished in 786ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'ruby-1.9.2@stealthygecko_rewrite' -c 'cd /home/deployer/apps/stealthygecko/releases/20120717222341 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'"

これが役立つかどうかを確認するために「config.assets.compile = false」を設定しようとしましたが、それでも同じエラーが発生します。

ここに私のデプロイスクリプトがあります:

server  "xx.xxx.xxx.xxx", :web, :app, :db, primary: true                                                                                                                                                    
depend :remote, :gem, "bundler", ">=1.1.3"                                                                                                                                                                  
depend :remote, :gem, "rake", ">=0.9.2.2"                                                                                                                                                                   

set :application, "stealthygecko"                                                                                                                                                                           
set :user, :"deployer"                                                                                                                                                                                      
set :deploy_to, "/home/#{user}/apps/#{application}"                                                                                                                                                         
set :deploy_via, :remote_cache                                                                                                                                                                              
set :use_sudo, false                                                                                                                                                                                        

set :scm, :git                                                                                                                                                                                              
set :repository, "git@github.com:StealthyGecko/stealthygecko.git"                                                                                                                                           
set :branch, "master"                                                                                                                                                                                       

default_run_options[:pty] = true                                                                                                                                                                            
set :ssh_options, {:forward_agent => true}                                                                                                                                                                  

set :ruby_version, "ruby-1.9.2"                                                                                                                                                                             
set :gemset_name, "stealthygecko_rewrite"                                                                                                                                                                   
set :rvm_ruby_gemset, "#{ruby_version}@#{gemset_name}"                                                                                                                                                      
set :bundle_without, [:darwin, :development, :test]                                                                                                                                                         

require "rvm/capistrano"                                                                                                                                                                                    
load 'deploy/assets'                                                                                                                                                                                        
set :rvm_ruby_string, "#{rvm_ruby_gemset}"                          # Select the gemset                                                                                                                     
set :rvm_type, :user                                                # RVM install is in the deploying user's home directory                                                                                 
#                                                                                                                                                                                                           
before "deploy:assets:precompile", "bundle:install"                                                                                                                                                         
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 "cd #{deploy_to}/current && /etc/init.d/unicorn_stealthygecko restart"                                                                                                                            

    end                                                                                                                                                                                                     
  end                                                                                                                                                                                                       

  task :setup_config, roles: :app do                                                                                                                                                                        
    puts "Symlinking nginx and unicorn configs"                                                                                                                                                             
    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                                                                                                                                                                      
    puts "Symlinking database yml"                                                                                                                                                                          
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"                                                                                                                    
    puts "Database Symlink done!"                                                                                                                                                                           
  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

私が読んださまざまなチュートリアルから一緒に石畳になっているのが少し混乱している場合はお詫びします。そして、ここに私のGemfileがあります:

source 'http://rubygems.org'                                                                                                                                                                                

gem 'rake'                                                                                                                                                                                                  
gem 'rails', '3.2.6'                                                                                                                                                                                        
gem 'mysql2'                                                                                                                                                                                                
gem 'bcrypt-ruby', '~> 3.0.0'                                                                                                                                                                               
gem 'gravtastic'                                                                                                                                                                                            
gem "friendly_id"                                                                                                                                                                                           
gem "rinku", '~>1.2.2', :require => 'rails_rinku'                                                                                                                                                           
gem "videawesome"                                                                                                                                                                                           
gem "will_paginate", "~>3.0.3"                                                                                                                                                                              
gem "tweet-button"                                                                                                                                                                                          
gem "bitly"                                                                                                                                                                                                 
gem "sanitize"                                                                                                                                                                                              
gem "newrelic_rpm"                                                                                                                                                                                          
gem 'capistrano'                                                                                                                                                                                            
gem 'rvm-capistrano'                                                                                                                                                                                        
gem "unicorn", "~> 4.2.1"                                                                                                                                                                                   
gem "twitter", "2.2.2"                                                                                                                                                                                      
gem 'instagram', :git => 'git://github.com/StealthyGecko/instagram-ruby-gem-lee.git'                                                                                                                        

group :assets do                                                                                                                                                                                            
  gem 'coffee-script'                                                                                                                                                                                       
  gem 'jquery-rails'                                                                                                                                                                                          
  gem 'uglifier'                                                                                                                                                                                            
  gem 'therubyracer'                                                                                                                                                                                        
  gem 'execjs'                                                                                                                                                                                              
  gem 'twitter-bootstrap-rails'                                                                                                                                                                             
end                                                                                                                                                                                                         

gem 'rspec-rails', :group => [:test, :development]                                                                                                                                                          
group :test do                                                                                                                                                                                              
  gem 'sqlite3'                                                                                                                                                                                             
  gem 'guard-rspec'                                                                                                                                                                                         
  gem 'capybara'                                                                                                                                                                                            
  gem 'launchy'                                                                                                                                                                                             
  gem 'shoulda', '3.0.0.beta2'                                                                                                                                                                              
  gem 'factory_girl_rails'                                                                                                                                                                                  
  gem 'ruby-debug19', :require => 'ruby-debug'                                                                                                                                                              
  gem 'turn', :require => false                                                                                                                                                                             
end 

私はそれが少し長いショットであることを知っていますが、誰かが私が間違っている場所を見つけることができる場合、または誰かがこの問題に遭遇してそれを解決することができた場合は、私に知らせてください。もう数時間。


失敗すると、「ロードするファイルがありません -- addressable/uri」と表示されますが、これがどこで使用されているのか、アセットのコンパイルに使用されている理由がわかりません

助言がありますか?

4

3 に答える 3

1

次のように修正されたようです: http://www.kudelabs.com/2012/03/28/rails-3-2-cap-deploy-with-assets


UPDATE2: cap スクリプトを見た後、before "deploy:assets:precompile", "bundle:install"

それを削除して追加してみてください:require 'bundler/capistrano'

それを削除load 'deploy/assets'して Capfile に入れます。


更新: rails generate rspec:install を見た後、「どのソースにも addressable-2.2.8 が見つかりませんでした」http://addressable.rubyforge.org/api/が返されます。

Gemfile.lock を確認してください

Using addressable (X.X.X) 

これはおそらく、Gemfile 内のいずれかの gem への依存関係であるはずです。それ以外の場合は、手動で追加してみてください。

私は持っている...

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

そして私のGemfile.lockで

...
addressable (2.2.8)
...

$ cat Capfile

load 'deploy/assets' のコメントを外す必要があります

load 'deploy'
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
Dir['vendor/gems/*/recipes/*.rb','vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
load 'config/deploy' # remove this line to skip loading any of the default tasks
于 2012-07-17T23:29:57.160 に答える
0

アセットをローカルでプリコンパイルしようとしましたか?

実行してみる

$ RAILS_ENV=prodution bundle exec rake assets:precompile
于 2012-07-17T23:24:45.387 に答える
0

Capfile から次の 2 行のコメントを外してアセットを完全に展開する必要がありました。そうしないと、フォントが展開されませんでした。

require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
于 2014-02-21T19:26:04.103 に答える