2016-03-22 86 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

相关问题