【问题标题】:rake assets:precompile error: File to import not found or unreadablerake 资产:预编译错误:找不到或无法读取要导入的文件
【发布时间】:2012-09-22 14:15:38
【问题描述】:

SO 中有一些类似的问题,但似乎没有一个包含解决我的问题的方法。

简单来说,为什么会出现以下错误,我该如何解决?

$ rake assets:precompile:all RAILS_ENV=production
rake aborted!
File to import not found or unreadable: bootstrap-clubicle.css.erb.
Load path: ~/Clubicle/Source/clubicle
  (in ~/Clubicle/Source/clubicle/app/assets/stylesheets/public_portal.css.scss)

@import 声明受到质疑并不奇怪。

@import 'bootstrap-clubicle.css.erb';

在样式表目录中确实存在 bootstrap-clubicle.css.erb 文件。

我在 OSX 10.6.8 上运行 Rails 3.1.1。

还值得注意的是,在 EngineYard 上部署我的应用时,我遇到了同样的错误。

【问题讨论】:

  • 我有时会在没有为运行 rake 任务的用户设置权限时得到这个。
  • 我认为这不是问题所在。权限似乎都很好。系统上只有一个用户。

标签: ruby-on-rails-3 asset-pipeline


【解决方案1】:

EngineYard的优秀支持人员终于查明了问题的原因。我有 application.css 中需要的文件(使用//= require),这些文件也包含在其他地方(使用@import)。双重导入导致了问题。

【讨论】:

    【解决方案2】:

    在解决这个问题几个小时后,我只想添加另一个对我有用的解决方案。

    我的 application.css 文件如下所示:

    /*
     * This is a manifest file that'll be compiled into application.css, which will include all the files
     * listed below.
     *
     * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
     * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
     *
     * You're free to add application-wide styles to this file and they'll appear at the top of the
     * compiled file, but it's generally better to create a new file per style scope.
     *
     */
    
    @import "base";
    

    注意,我拿出来了:

     *= require_self
     *= require_tree .
    

    因为我正在使用 @import 指令导入另一个 Sass 文件。

    我不得不删除整个评论——不仅仅是让 Sass 找到我的 @import “base”的要求。一旦我这样做了,就会找到导入并预编译应用程序。

    【讨论】:

      猜你喜欢
      • 2013-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-07
      • 2017-04-11
      • 1970-01-01
      • 2019-10-26
      • 1970-01-01
      相关资源
      最近更新 更多