rake资产:预编译失败

时间:2013-03-20 22:58:35

标签: ruby-on-rails rake asset-pipeline production

我有一个Rails应用程序,在开发中运行良好。我正在使用RubyMine开发它,但是我使用Webrick和sqlite3在终端上测试并运行它(文件存储/运行在我从OSX使用Terminal访问的Ubuntu工作站上)。 该应用程序使用修改后的Boostrap模板,它工作正常。 现在我想尝试在生产模式下运行它。

这就是我所做的: Rails版本是3.2.11,我使用rvm 1.8.1和ruby-1.9.2-p290

config.logger = Logger.new(STDOUT) in environment/production.rb
config.serve_static_assets = true in environment/production.rb
export RAILS_ENV=production
rake db:migrate (works fine)
rake assets:precompile --trace

我收到以下错误:

peter@fshsweden:/var/www/prod/mackmyra2.dnsalias.com$ rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/home/peter/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /home/peter/.rvm/gems/ruby-1.9.2-p290/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
Compiled jquery.js  (2ms)  (pid 4521)
Compiled jquery_ujs.js  (0ms)  (pid 4521)
Compiled bootstrap.js  (0ms)  (pid 4521)
Compiled articles.js  (68ms)  (pid 4521)
Compiled lightbox.js  (0ms)  (pid 4521)
Compiled main.js  (0ms)  (pid 4521)
Compiled prettify.js  (0ms)  (pid 4521)
Compiled public.js  (1ms)  (pid 4521)
Compiled small_articles.js  (0ms)  (pid 4521)
Compiled application.js  (142ms)  (pid 4521)
Compiled application.css  (4744ms)  (pid 4521)
rake aborted!
/var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb:6: syntax error, unexpected     ')'
... 'form-horizontal'} ) do |ff| ).to_s); _erbout.concat "\n"
...                               ^
/var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb:45: syntax error, unexpected     keyword_ensure, expecting ')'
/var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb:47: syntax error, unexpected     keyword_end, expecting ')'
  (in /var/www/prod/mackmyra2.dnsalias.com/app/views/articles/_form.html.erb)
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:209:in `instance_eval'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:209:in `evaluate_source'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:144:in `cached_evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:127:in `evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in     `cache_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in     `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in     build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/static_compiler.rb:19:in `block in compile'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/static_compiler.rb:18:in `compile'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:56:in `internal_precompile'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/peter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/home/peter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in     `invoke_with_call_chain'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `load'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/home/peter/.rvm/rubies/ruby-1.9.2-p290/bi...]
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in     create_shell_runner'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils.rb:80:in `ruby'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `ruby'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:12:in     `ruby_rake_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.11/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in     invoke_with_call_chain'
/home/peter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:159:in     `invoke_with_call_chain'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/home/peter/.rvm/gems/ruby-1.9.2-p290/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `load'
/home/peter/.rvm/gems/ruby-1.9.2-p290/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile

现在,如果我在干净的rails应用程序上执行上述操作,则可以正常工作。但它在我的应用程序上失败,我认为它正在工作。你能指出什么是错的吗?

_form.rb是一个带有simple_form调用的部分,没什么特别的。

(这里只显示两行以显示错误似乎发生的位置)

<%= yield :title %>
<%= simple_form_for(@article, :html => {:multipart => true, :class => 'form-horizontal'} ) do |ff| %>

感谢任何帮助!

1 个答案:

答案 0 :(得分:1)

好的,结果证明这是我的蠢事。在几周前解决其他一些资产问题时,我已经摆弄了(在config / application.rb中)

config.assets.paths << "#{Rails.root}/app/assets"

并且意外地添加了(在某些绝望的举动中我猜)

config.assets.paths << "#{Rails.root}/app"

这当然包括应用程序中的所有内容作为资产,这是非常错误的。

这个错误确实出现了,直到我不得不做一个rake资产:precompile。由于我并没有真正了解该命令的作用,我没有看到它试图将视图ERB文件编译为资产。

找到这篇文章之后:http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-2-production/我意识到它错误地包含了视图文件,而且它必须是一个路径问题。

小错误但很难修复。 Rails标准的排序。