简体   繁体   English

耙资产:预编译失败

[英]rake assets:precompile fails

I have an Rails app that is working fine in development. 我有一个在开发中运行良好的Rails应用程序。 I'm developing it in RubyMine but I test and run it from the Terminal (files are stored/run on a Ubuntu workstation that I access with Terminal from OSX) using Webrick and sqlite3. 我正在RubyMine中进行开发,但是我使用Webrick和sqlite3从Terminal测试并运行了它(文件存储在/可以从OSX通过Terminal访问的Ubuntu工作站上运行)。 The app uses a modified Boostrap-template and it works fine. 该应用程序使用了经过修改的Boostrap模板,并且运行良好。 Now I wanted to try to run it in production mode. 现在,我想尝试在生产模式下运行它。

This is what I did: Rails version is 3.2.11, I use rvm 1.8.1 with ruby-1.9.2-p290 这就是我所做的: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

I get the following error: 我收到以下错误:

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

Now if I do the above on a clean rails app, it works. 现在,如果我在干净的Rails应用程序上执行上述操作,则它可以工作。 But it fails on my app that I thought was working. 但是我认为我的应用无法正常运行。 Can you give any pointers about what is wrong? 您能指出什么地方出了问题吗?

The _form.rb is btw a partial with a simple_form call, nothing special at all. _form.rb是带有simple_form调用的部分,根本没有什么特别的。

(Just two lines shown here to show where the error seems to occur) (这里仅显示了两行,以显示似乎在哪里发生错误)

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

Any help is appreciated! 任何帮助表示赞赏!

OK this turned out to be a goof by me. 好吧,事实证明这对我来说是愚蠢的。 When solving some other asset problem a few weeks ago, I had fiddled around with (in config/application.rb) 几周前解决其他资产问题时,我在(config / application.rb)中摆弄

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

and accidentally added (In some desperate move I guess) 并意外添加(我猜是在一些绝望的举动中)

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

This of course included EVERYTHING under app as assets, which was horribly wrong. 当然,这包括应用程序下的所有内容作为资产,这是完全错误的。

This error did show up until I had to do a rake assets:precompile. 直到我不得不执行rake asset:precompile时,此错误才出现。 Since I didnt really have a clue what that command did, I didn't see that it was trying to compile view ERB files as assets. 由于我实际上并不知道该命令的功能,因此我没有看到它试图将View ERB文件作为资产进行编译。

After finding this article: http://blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-2-production/ I realised that it was erroneously including the view files and it had to be a path problem. 找到这篇文章之后: http : //blog.55minutes.com/2012/02/untangling-the-rails-asset-pipeline-part-2-production/我意识到它错误地包含了视图文件,必须将路径问题。

Small error but very difficult to fix. 错误很小,但很难修复。 Sort of the Rails standard. 符合Rails标准。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM