两天后,我无法再在我的ruby on rails项目中编译javascript资产。如果我不运行预编译命令,则当ruby在运行时编译资产时会发生同样的错误。 'rake assets:precompile'命令因分段错误而中止:
bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/Roseboom/.rvm/rubies/ruby-1.9.3-p125/bin/ruby /home/Roseboom/.rvm/gems/ruby-1.9.3-p125/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
sh: regel 1: 15071 Segmentatiefout node /tmp/execjs20120417-15062-69pd5q.js 2>&1
rake aborted!
["ok","(function() {\n\n\n\n}).call(this);\n"]
(in /home/Roseboom/gitControlled/ror/livescore/app/assets/javascripts/clubs.js.coffee)
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:150:in `exec_runtime'
[.... Remaining stacktrace below this post for the sake of readability ]
在这里,'Segmentatiefout'是'分段错误'的荷兰语。 起初,我以为我搞乱了我的项目,我开始恢复变化以隔离“坏”变化。当这没有帮助的时候,我在一个项目中尝试了“捆绑exec rake资产:预编译”,这个项目我几周都没用,这给我带来了相同的分段错误。
现在我试图找到这个“execjs20120417-15062-69pd5q.js”文件来删除它。即使借助unix'find'命令,我也找不到。也许这个临时文件即使在中止时也会被清除。
我接下来尝试的是重新安装rake,这对我没有帮助。虽然在运行'rake assets:precompile'时出现了同样的错误,但我也尝试重新安装bundler。这也没有用。
接下来的事情有点严厉,我在我的系统上重新安装了ruby和rails。不幸的是,根本没有变化。 Rails版本是3.2.2,重新安装后它是3.2.3。
我尝试的最后一件事是卸载gem execjs,并重新安装它,但也没有帮助。
将RAILS_ENV更改为开发也不会改变任何内容。
当我清除app / assets / javascripts文件夹时,我可以预编译,我可以运行我的应用程序(如Rails assets precompile mysterious error中所述)。我希望ruby能够使用之前成功编译的资产。但是,这意味着我永远不能更改app / assets / javascripts的内容,这是不可取的。如果我删除了那里的所有.js.coffee文件,则会在剩下的.js文件上发生分段错误。
文件clubs.js.coffee是自动生成的,我从未改变过。它是在几周前生成的,并且在2天前从未遇到过我的问题。如果我删除它,同样的故障只发生在另一个.coffe或.js文件中。 clubs.js.coffee包含:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
我真的没有想法。在此先感谢您的帮助。
完整的堆栈跟踪:
bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/Roseboom/.rvm/rubies/ruby-1.9.3-p125/bin/ruby /home/Roseboom/.rvm/gems/ruby-1.9.3-p125/bin/rake assets:precompile:
all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
sh: regel 1: 15936 Segmentatiefout node /tmp/execjs20120417-15927-1ka3s2r.js 2>&1
rake aborted!
["ok","(function() {\n\n\n\n}).call(this);\n"]
(in /home/Roseboom/gitControlled/ror/livescore/app/assets/javascripts/clubs.js.coffee)
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:150:in `exec_runtime'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:27:in `block in exec'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:40:in `compile_to_tempfile'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:26:in `exec'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:18:in `eval'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/execjs-1.3.0/lib/execjs/external_runtime.rb:32:in `call'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/coffee-script-2.2.0/lib/coffee_script.rb:57:in `compile'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/coffee.rb:46:in `evaluate'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/context.rb:177:in `block in evaluate'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/context.rb:174:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/context.rb:174:in `evaluate'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:12:in `initialize'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `new'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `block in build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:262:in `circular_call_protection'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:240:in `build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:106:in `block in build_required_assets'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:100:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:100:in `build_required_assets'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:16:in `initialize'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `new'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `block in build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:262:in `circular_call_protection'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:240:in `build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:244:in `new'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:244:in `build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/static_compiler.rb:20:in `block in compile'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:212:in `block in each_logical_path'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:200:in `block (2 levels) in each_file'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:190:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:190:in `each_entry'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:198:in `block in each_file'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:197:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:197:in `each_file'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/sprockets-2.1.2/lib/sprockets/base.rb:210:in `each_logical_path'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/static_compiler.rb:18:in `compile'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/assets.rake:56:in `internal_precompile'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/assets.rake:70:in `block (3 levels) in <top
(required)>'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/Roseboom/.rvm/rubies/ruby-1.9.3-p125/lib64/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/assets.rake:60:in `block (3 levels) in <top
(required)>'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/Roseboom/.rvm/rubies/ruby-1.9.3-p125/lib64/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/Roseboom/.rvm/rubies/ruby-1.9.3-p125...]
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/assets.rake:12:in `ruby_rake_task'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/actionpack-3.2.3/lib/sprockets/assets.rake:29:in `block (2 levels) in <top
(required)>'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/Roseboom/.rvm/rubies/ruby-1.9.3-p125/lib64/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
/home/Roseboom/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile
答案 0 :(得分:2)
尝试将execjs更改为therubyracer gem。在我切换到rubyracer之前,我有很多execjs的问题。现在一切正常。
group :assets do
gem 'sass'
gem 'coffee-script'
gem 'uglifier'
gem 'therubyracer'
end
干杯!
答案 1 :(得分:0)
在我的情况下,这是因为我使用了错误的Ruby版本。记住要仔细检查项目的Ruby版本