Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 在生产服务器上编译资产时出错_Ruby_Ruby On Rails 4_Asset Pipeline_Sprockets_Capistrano3 - Fatal编程技术网

Ruby 在生产服务器上编译资产时出错

Ruby 在生产服务器上编译资产时出错,ruby,ruby-on-rails-4,asset-pipeline,sprockets,capistrano3,Ruby,Ruby On Rails 4,Asset Pipeline,Sprockets,Capistrano3,我尝试使用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/

我尝试使用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
Centos 5
ruby 2.1.3p242 (managed by rbenv)
这是我的生产环境:

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
Centos 5
ruby 2.1.3p242 (managed by rbenv)
我当前安装的gems是:

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)

这与我最初的问题有关联吗?

对于任何遇到这一问题的人来说,由于@DavidK-J发布的链接为我指明了正确的方向,问题得以解决。我需要使用rbenv的设置更新cap文件,如下所示:

卡普里

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
还有其他人


Paul

你确定这不是Rubygems站点的一个短暂故障吗?
未定义的方法“to_h”for nil:NilClass
“告诉我们的不多。它还应该告诉你行号和它所在的文件。您有一个未初始化的值,但我们不知道它是什么。您发布了日志中不可用的部分,而这部分是在ruby 1.9.1下运行的。也许这就是问题所在?正如Mike之前提到的,Capistrano似乎在运行不同的Ruby。也许是你?@David K-J谢谢,那篇帖子似乎可以解决这个问题。直到星期四我才能再次访问服务器,因此我将在星期四再试一次。