9

我正在使用 ruby​​ 1.9,当我在我的 rails 应用程序中运行“rake assets:precompile”时,它失败并返回了这个:

rake aborted!

undefined method 'bytesize' for true:TrueClass

~/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/utils.rb:282:in 'bytesize'

utils.rb 中失败的代码部分是这样的(第 280-289 行):

if ''.respond_to?(:bytesize)
  def bytesize(string)
    string.bytesize
  end
else
  def bytesize(string)
    string.size
  end
end
module_function :bytesize

第 282 行是第三行,string.bytesize。

我找到了许多类似问题的解决方案,但没有一个能够解决这个问题。一些建议是更改 environment/production.rb 中的代码并更改 Gemfile 中 gem 的顺序,但是这两种解决方案都不适合我。任何建议将不胜感激。顺便说一句,我使用的是 rack v 1.4.1。

谢谢!

完整的跟踪:

** Invoke assets:precompile (first_time)  
** Execute assets:precompile  
/usr/local/bin/ruby /usr/local/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  
rake aborted!  
undefined method 'bytesize' for true:TrueClass  
~/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/utils.rb:281:in 'bytesize'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/processed_asset.rb:13:in 'initialize'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in 'new'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:241:in 'block in build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:262:in 'circular_call_protection'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:240:in 'build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in 'block in build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in 'cache_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in 'build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in 'find_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in 'find_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/bundled_asset.rb:16:in 'initialize'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in 'new'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:244:in 'build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:89:in 'block in build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/caching.rb:19:in 'cache_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:88:in 'build_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:163:in 'find_asset'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/index.rb:56:in 'find_asset'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/static_compiler.rb:23:in 'block in compile'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:212:in 'block in each_logical_path'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:200:in 'block (2 levels) in each_file'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in 'each'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:190:in 'each_entry'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:198:in 'block in each_file'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in 'each'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:197:in 'each_file'  
~/shared/bundle/ruby/1.9.1/gems/sprockets-2.1.3/lib/sprockets/base.rb:210:in 'each_logical_path'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/static_compiler.rb:18:in 'compile'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/assets.rake:56:in 'internal_precompile'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/assets.rake:70:in 'block (3 levels) in <top (required)>'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in 'call'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in 'block in execute'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in 'each'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in 'execute'  
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in 'mon_synchronize'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in 'invoke_with_call_chain'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in 'invoke'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/assets.rake:60:in 'block (3 levels) in <top (required)>'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in 'call'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in 'block in execute'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in 'each'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in 'execute'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in 'block in invoke_with_call_chain'  
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in 'mon_synchronize'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in 'invoke_with_call_chain'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in 'invoke'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in 'invoke_task'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in 'block (2 levels) in top_level'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in 'each'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in 'block in top_level'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in 'standard_exception_handling'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in 'top_level'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in 'block in run'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in 'standard_exception_handling'  
~/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in 'run'  
/usr/local/bin/rake:32:in '<main>'  
Tasks: TOP => assets:precompile:primary  
rake aborted!  
Command failed with status (1): [/usr/local/bin/ruby /usr/local/bin/rake as...]  
/usr/local/lib/ruby/1.9.1/rake/file_utils.rb:53:in 'block in create_shell_runner'  
/usr/local/lib/ruby/1.9.1/rake/file_utils.rb:45:in 'call'  
/usr/local/lib/ruby/1.9.1/rake/file_utils.rb:45:in 'sh'  
/usr/local/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in 'sh'  
/usr/local/lib/ruby/1.9.1/rake/file_utils.rb:80:in 'ruby'  
/usr/local/lib/ruby/1.9.1/rake/file_utils_ext.rb:39:in 'ruby'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/assets.rake:12:in 'ruby_rake_task'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/assets.rake:21:in 'invoke_or_reboot_rake_task'  
~/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.8/lib/sprockets/assets.rake:29:in 'block (2 levels) in <top (required)>'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:205:in 'call'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:205:in 'block in execute'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:200:in 'each'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:200:in 'execute'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:158:in 'block in invoke_with_call_chain'  
/usr/local/lib/ruby/1.9.1/monitor.rb:211:in 'mon_synchronize'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:151:in 'invoke_with_call_chain'  
/usr/local/lib/ruby/1.9.1/rake/task.rb:144:in 'invoke'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:116:in 'invoke_task'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:94:in 'block (2 levels) in top_level'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:94:in 'each'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:94:in 'block in top_level'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:133:in 'standard_exception_handling'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:88:in 'top_level'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:66:in 'block in run'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:133:in 'standard_exception_handling'  
/usr/local/lib/ruby/1.9.1/rake/application.rb:63:in 'run'  
/usr/local/bin/rake:32:in '<main>'  
Tasks: TOP => assets:precompile 
4

0 回答 0