【问题标题】:rake assets:precompile errorrake 资产:预编译错误
【发布时间】:2012-11-20 06:40:23
【问题描述】:

在我的生产服务器上运行 rake assets:precompile 时出现错误。据我所知,在这件事发生之前我没有做任何不同的事情。在我的开发机器上运行rake assets:precompile 不会产生任何错误。我不确定如何调试它。建议?我尝试使用 --trace 选项运行,但它并没有真正为我提供更多有用的信息来指出代码中的错误。

deploy@example.com:~/www/example.com/app/assets/stylesheets$ rake assets:precompile
(in /home/deploy/www/example.com)
/home/deploy/.rvm/rubies/ruby-1.9.3-p194/bin/ruby /home/deploy/.rvm/gems/ruby-1.9.3-p194@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Invalid CSS after "...4882640c.png"")": expected "{", was ";background-pos..."
  (in /home/deploy/www/example.com/app/assets/stylesheets/application.css)

Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/home/deploy/.rvm/rubies/ruby-1.9.3-p194/b...]

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

【问题讨论】:

  • 我们需要查看上面错误中引用的 CSS 段 - 看起来可能是语法错误。
  • 是的,所以问题是我在我的开发机器上使用完全相同的 CSS 文件,当我运行 rake:assets precompile RUBY_ENV=development 时我没有收到此错误。
  • 只是大声思考,您的 Gemfile 的开发部分中是否有可能导致此问题的 gem?例如。萨斯?
  • 我在资产组中有sass-rails 以及twitter-bootstrap-rails

标签: ruby-on-rails twitter-bootstrap rake twitter-bootstrap-rails


【解决方案1】:

你在 application.css 文件中有错误

它说

Invalid CSS after "...4882640c.png"")": expected "{", was ";background-pos..."

看起来就是你设置背景图片的地方。

如果您需要帮助来查找错误。发布css文件

【讨论】:

    【解决方案2】:

    Andreas Lyngstad 所说的大部分是正确的,除了当您对资产运行预编译时,所有内容都被添加到 application.css 文件中,因此错误不一定在该文件中,只是您在某处有错误在 application.css 文件中包含的任何 css 文件中。因此,您需要检查包含的所有 css 文件中是否存在该错误,您可以对所有 css 文件进行文本搜索,并尝试根据您使用的任何编辑器找到该行。

    无论如何,希望这会有所帮助。

    【讨论】:

      【解决方案3】:

      我最终解决了这个问题。事实证明,这是我使用的 Twitter bootstrap rails gem 的问题。我正在使用https://github.com/seyhunak/twitter-bootstrap-rails。事实证明,这是在 bootstrap_and_overrides.less 文件中导入的一张工作表中的错误。我的解决方案是将我的 Gemfile 中的 gem 冻结到 2.1.7 版,并处理之后出现的任何依赖问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-11-04
        • 1970-01-01
        • 1970-01-01
        • 2016-04-18
        • 1970-01-01
        • 2014-02-19
        相关资源
        最近更新 更多