Rails rake assets:precompile 错误

bryanwong · 2012年02月16日 · 最后由 lilu 回复于 2012年03月17日 · 6339 次阅读

报错 rake aborted! undefined method `info' for true:TrueClass

grep 不到哪里有 info 和 TrueClass 啊。

大家知道是什么问题吗?


$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/bryan/.rvm/rubies/ruby-1.9.3-p0/bin/ruby /home/bryan/.rvm/gems/ruby-1.9.3-p0/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 `info' for true:TrueClass
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:22:in `initialize'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `new'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `block in build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:262:in `circular_call_protection'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:240:in `build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:106:in `block in build_required_assets'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:100:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:100:in `build_required_assets'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:16:in `initialize'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `new'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `block in build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:262:in `circular_call_protection'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:240:in `build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:244:in `new'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:244:in `build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/static_compiler.rb:20:in `block in compile'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:212:in `block in each_logical_path'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:200:in `block (2 levels) in each_file'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:190:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:190:in `each_entry'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:198:in `block in each_file'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:197:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:197:in `each_file'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/sprockets-2.1.2/lib/sprockets/base.rb:210:in `each_logical_path'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/static_compiler.rb:18:in `compile'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/assets.rake:52:in `internal_precompile'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/assets.rake:66:in `block (3 levels) in <top (required)>'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/bryan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/bryan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/bryan/.rvm/rubies/ruby-1.9.3-p0/bin/...]
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.1/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/bryan/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
/home/bryan/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile


我也有同样的问题。有人知道如何解决吗?

@bryanwong @foyo99 两位用bundle exec rake assets:precompile试试 即在 bundle 里执行 rake

@willmouse 谢谢回复。不是这个原因。这个问题我暴力解决了。原因是 config/environments/production.rb 中的这句“config.assets.precompile = true”引起的。把它注释掉就 OK 了。

#3 楼 @foyo99 config.assets.precompile 是一个 Array,放需要预编译的文件名

楼上正解

config.assets.precompile = ['one.js', 'other.js']

需要预编译的 js 一般是不加入 application.js 的 manifest 中的库

gsky 求助,rake assets:precompile 报错 (已解决) 提及了此话题。 04月03日 10:57
需要 登录 后方可回复, 如果你还没有账号请 注册新账号