Rails 4.2.0资产预编译错误“错误的参数类型为nil(预期数据)”

时间:2016-06-28 14:34:32

标签: ruby-on-rails-4 precompile therubyracer libv8

我在CentOS 6.6 Linux上使用RubyOnRails 4.2.0构建了网站。 我不能资产预编译CoffeeScript。 宝石“therubyracer”运行时似乎发生了错误。 仅当CoffeeScript不存在时,预编译才会成功。

我使用gem“therubyracer”ver.0.11.0beta8和gem“libv8”ver.3.11.8.3。 怎么解决? 感谢。

架构

# bundle exec ruby -rubygems -e 'puts Gem::Platform.new(RUBY_PLATFORM)'
x86_64-linux

Rails.application.config.assets

irb(main):001:0> y Rails.application.config.assets.compile
--- true
...
=> nil
irb(main):002:0>
irb(main):003:0*
irb(main):004:0* y Rails.application.config.assets.digest
--- true
...
=> nil
irb(main):005:0> y Rails.application.config.assets.enabled
--- true
...
=> nil
irb(main):006:0>
irb(main):011:0* y Rails.application.config.assets.paths
---
- "/opt/redmine-3.0.1/app/assets/javascripts"
- "/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/websocket-rails-0.7.0/lib/assets/javascripts"
- "/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/jquery-rails-3.1.2/vendor/assets/javascripts"
- "/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/coffee-rails-4.1.1/lib/assets/javascripts"
=> nil
irb(main):012:0>
irb(main):013:0* y Rails.application.config.assets.precompile
---
- !ruby/object:Proc {}
- !ruby/regexp /(?:¥/|¥¥|¥A)application¥.(css|js)$/
- "*.coffee"
- "*.js"
- "*.jpg"
- "*.png"
- "*.ttf"
=> nil
irb(main):014:0>
irb(main):015:0* y Rails.application.config.assets.prefix
--- "/assets"
=> nil
irb(main):016:0>

资产目录

# cat app/assets/javascripts/application.js
//= require websocket_rails/main

# ls -ltr /opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/websocket-rails-0.7.0/lib/assets/javascripts/
合計 4
drwxr-xr-x 2 root root 4096  6月 26 18:46 2016 websocket_rails

# ls -ltr /opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/websocket-rails-0.7.0/lib/assets/javascripts/websocket_rails/
合計 32
-rw-r--r-- 1 root root 1742  6月 19 17:53 2016 http_connection.js.coffee
-rw-r--r-- 1 root root  995  6月 19 17:53 2016 event.js.coffee
-rw-r--r-- 1 root root 2292  6月 19 17:53 2016 channel.js.coffee
-rw-r--r-- 1 root root 1237  6月 19 17:53 2016 abstract_connection.js.coffee
-rw-r--r-- 1 root root 4515  6月 19 17:53 2016 websocket_rails.js.coffee
-rw-r--r-- 1 root root  857  6月 19 17:53 2016 websocket_connection.js.coffee
-rw-r--r-- 1 root root  171  6月 19 17:53 2016 main.js
# cat /opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/websocket-rails-0.7.0/lib/assets/javascripts/websocket_rails/main.js
//= require ./websocket_rails
//= require ./event
//= require ./abstract_connection
//= require ./http_connection
//= require ./websocket_connection
//= require ./channel

rake assets:precompile

# RAILS_ENV=production bundle exec rake assets:precompile --trace
[DEPRECATION] requiring "RMagick" is deprecated. Use "rmagick" instead
** Invoke assets:precompile (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Execute assets:precompile
rake aborted!
TypeError: wrong argument type nil (expected Data)
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/therubyracer-0.11.0beta8-x86_64-linux/lib/v8/context.rb:66:in `New'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/therubyracer-0.11.0beta8-x86_64-linux/lib/v8/context.rb:66:in `initialize'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:10:in `new'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:10:in `block in initialize'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:75:in `block in lock'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:73:in `call'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:73:in `Locker'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:73:in `lock'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/ruby_racer_runtime.rb:9:in `initialize'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/runtime.rb:44:in `new'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/runtime.rb:44:in `compile'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/module.rb:27:in `compile'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/coffee-script-2.4.1/lib/coffee_script.rb:50:in `context'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/coffee-script-2.4.1/lib/coffee_script.rb:78:in `compile'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/coffee_script_processor.rb:21:in `block in call'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cache.rb:85:in `fetch'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/coffee_script_processor.rb:20:in `call'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:73:in `call_processor'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:55:in `block in call_processors'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:54:in `reverse_each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:54:in `call_processors'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:103:in `load_asset_by_uri'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:40:in `block in load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:170:in `fetch_asset_from_dependency_cache'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:33:in `load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cached_environment.rb:47:in `yield'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cached_environment.rb:47:in `load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/bundle.rb:23:in `block in call'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/utils.rb:183:in `dfs'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/bundle.rb:24:in `call'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:73:in `call_processor'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:55:in `block in call_processors'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:54:in `reverse_each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/processor_utils.rb:54:in `call_processors'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:103:in `load_asset_by_uri'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:40:in `block in load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:170:in `fetch_asset_from_dependency_cache'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/loader.rb:33:in `load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cached_environment.rb:47:in `yield'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/cached_environment.rb:47:in `load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/base.rb:63:in `find_asset'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/base.rb:70:in `find_all_linked_assets'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/manifest.rb:138:in `block in find'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/path_utils.rb:204:in `each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/path_utils.rb:204:in `stat_directory'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/path_utils.rb:222:in `stat_tree'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/legacy.rb:105:in `each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/legacy.rb:104:in `each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/legacy.rb:104:in `logical_paths'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/manifest.rb:136:in `find'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/sprockets/manifest.rb:162:in `compile'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-3.0.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/bin/rake:23:in `load'
/opt/redmine-3.0.1/vendor/bundle/ruby/2.1.0/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile
#

1 个答案:

答案 0 :(得分:0)

libv8 maintainer here.

The versions of libv8 and therubyracer you're using are ancient, please consider updating to the newest released versions. If you continue receiving errors, please consider opening up an issue in therubyracer's/libv8's issue trackers in github.

As a side note, you should consider asking the maintainers of a project directly first, through their issue tracker for example, before shooting a question in SO. Your question probably would have remained unanswered had I not been by chance looking for recent questions about libv8 here.