5

嘿夥計我試圖將我的rails 3.2.6應用程序部署到生產環境中,部署似乎很順利,直到它獲得在此預編譯的資產是我得到的錯誤:使用Twitter-Bootstrap-Rails在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 '[email protected]_rewrite' -c 'cd /home/deployer/apps/stealthygecko/releases/20120717222341 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile'" 

我試過設置「config.assets.compile =假」,看看這可以幫助,但我仍然得到同樣的錯誤。

這裏是我的部署腳本:

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, "[email protected]: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 

我知道它有點長鏡頭,但如果任何人能發現我要去哪裏錯了或者是否有人已經遇到了這個問題,並設法解決它,請讓我知道,因爲我現在幾個小時一直在反駁這個問題。


失敗時它似乎在說「沒有這樣的文件來加載 - 尋址/ URI」但我不知道在哪裏,這是正在使用和爲什麼它被用於編制資產

任何建議?

+0

是資產com在服務器上使用打包器進行預編譯?看起來像一個依賴加載問題。 – joshnesbitt 2012-07-18 10:07:22

+0

是的,或者至少它是在最後部署 – 2012-07-18 12:57:16

回答

1

顯然固定如下:http://www.kudelabs.com/2012/03/28/rails-3-2-cap-deploy-with-assets


UPDATE2:看你的帽子腳本之後,你有before "deploy:assets:precompile", "bundle:install"

嘗試刪除和添加:require 'bundler/capistrano'

Remov e load 'deploy/assets'並將其放入您的Capfile中。


UPDATE:看rails generate rspec:install returns 'Could not find addressable-2.2.8 in any of the sources'http://addressable.rubyforge.org/api/後。

檢查Gemfile.lock的

Using addressable (X.X.X) 

這也許應該是一個依賴於你的Gemfile的寶石之一。否則,您可以嘗試手動添加它。

我有...

... 
# 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。鎖定

... 
addressable (2.2.8) 
... 

$ cat Capfile 

您必須解除負載「部署/資產」

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 
+0

嗨@Moriarty,感謝您的回覆,這裏是我的Capfile: 'load 'deploy' require「bundler/capistrano」 Dir ['vendor/gems/*/recipes/*。rb','vendor/plugins/*/recipes/*。rb']。加載'插件}} load'config/deploy'#刪除這一行以跳過加載任何默認任務 加載'deploy/assets'' 正如你所看到的,我已經取消註釋了你提到的那一行。 – 2012-07-18 08:52:49

+0

羅傑。我更新了我的帖子。 – Moriarty 2012-07-19 22:27:36

+0

擊@Moriarty再次感謝您的繼續幫助。檢查過Gemfile.lock及其三個地方,第一個是自己的,然後是launchy和libwebsocket的依賴項。我也試圖使用與您在文章中描述的相同的資產組,並且可悲的是它仍抱怨它無法加載可尋址/ uri這開始變得非常令人沮喪。 – 2012-07-19 23:48:59

0

您是否嘗試過在本地預編譯資產?

嘗試運行

$ RAILS_ENV=prodution bundle exec rake assets:precompile 
+0

感謝您的repsonse @quilyquinto,我試過這個,它預編譯沒有本地問題 – 2012-07-18 09:09:10

0

我不得不額外註釋掉從我Capfile以下兩行,以獲得資產全面部署,否則字體沒有部署:

require 'capistrano/rails/assets' 
require 'capistrano/rails/migrations'