2016-03-22 85 views
0

我試圖部署與Capistrano的我的Rails應用程序在編譯的資產,並得到了以下錯誤:錯誤當生產服務器

NoMethodError: undefined method `to_h' for nil:NilClass 

這裏是堆棧跟蹤,它看起來像它可能是一個鏈輪的問題,但我想不通爲什麼:

/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:14:in `configuration_hash' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:40:in `configuration_hash' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:44:in `initialize' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:21:in `new' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:21:in `instance' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-es6-0.9.0/lib/sprockets/es6.rb:34:in `call' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:75:in `call_processor' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `reverse_each' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `call_processors' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:134:in `load_from_unloaded' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:60:in `block in load' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:44:in `load' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:20:in `block in initialize' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `yield' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `default' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `load' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/bundle.rb:23:in `block in call' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/utils.rb:183:in `dfs' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/bundle.rb:24:in `call' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:75:in `call_processor' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `reverse_each' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `call_processors' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:134:in `load_from_unloaded' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:60:in `block in load' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/loader.rb:44:in `load' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:20:in `block in initialize' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `yield' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `default' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/cached_environment.rb:47:in `load' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/base.rb:66:in `find_asset' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/base.rb:73:in `find_all_linked_assets' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:142:in `block in find' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/path_utils.rb:225:in `block in stat_tree' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/path_utils.rb:209:in `block in stat_directory' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/path_utils.rb:206:in `each' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/path_utils.rb:206:in `stat_directory' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/path_utils.rb:224:in `stat_tree' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/legacy.rb:105:in `each' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/legacy.rb:105:in `block in logical_paths' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/legacy.rb:104:in `each' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/legacy.rb:104:in `logical_paths' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:140:in `find' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/sprockets/manifest.rb:168:in `compile' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-3.5.2/lib/rake/sprocketstask.rb:147:in `with_logger' 
/var/www/paperless_office/shared/bundle/ruby/1.9.1/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define' 
Tasks: TOP => assets:precompile 

這是我的本地環境:

OSX 10.11.3 
Ruby 2.1.3p242 
Rails 4.1.0 
Rake 10.3.2 
Sprockets-Rails 2.3.3 
Capistrano 3.4.0 

這爲m Ÿ生產環境:

Centos 5 
ruby 2.1.3p242 (managed by rbenv) 

我當前安裝的寶石:

bigdecimal (1.2.4) 
bundler (1.11.2) 
io-console (0.4.2) 
json (1.8.1) 
minitest (4.7.5) 
psych (2.0.5) 
rake (10.1.0) 
rdoc (4.1.0) 
test-unit (2.1.3.0) 

我已經能夠運行:

gem install bundler 

但是,如果我運行:

gem install rails 

我收到:

ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) 
    bad response Service Unavailable 503 (https://api.rubygems.org/api/v1/dependencies?gems=rack) 

這是否與我最初的問題有關?

+0

您確定這不是Rubygems網站的簡短故障嗎? – tadman

+0

「對於nil:NilClass」未定義的方法'to_h'「並沒有說明什麼。它也應該告訴你行號和它發生的文件。你有一個未初始化的值,但我們不知道它會是什麼。 –

+0

您發佈了無用的部分日誌,並且這部分是在ruby 1.9.1下運行的。也許這是抓住? –

回答

0

對於任何遇到此問題的人來說,由於@ DavidK-J發佈的鏈接指出我的方向正確,問題得到解決。我需要更新與rbenv設置的上限文件內容如下:

Capfile

require 'capistrano/rbenv' 

deploy.rb

set :rbenv_type, :system 
set :rbenv_path, '~/.rbenv' 
set :rbenv_ruby, "2.1.3" 
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" 
set :rbenv_map_bins, %w{rake gem bundle ruby rails} 
set :rbenv_roles, :all 

我只好再更新乘客的配置與路徑rbenv哪些在我的情況是:

~/.rbenv 

HTH別人。

Paul

相關問題