【问题标题】:Error: Sprockets::FileNotFound: couldn't find file 'application.scss' for Heroku错误:Sprockets::FileNotFound: 找不到 Heroku 的文件 'application.scss'
【发布时间】:2015-11-16 18:53:12
【问题描述】:

我遇到了一些问题,Sprockets 在 rake assets:precompile 期间找不到文件。我以前没有遇到过这个问题,但是当我添加生成的迁移(在本地构建)时,Heroku 无法构建我的应用程序,我不知道为什么,因为它是在本地构建的(没有我运行额外的 rake 资产:预编译)。

错误信息是这样的:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Sprockets::FileNotFound: could not find file: /tmp/build_dd4a799769e6963b7b292df72db58fd8/username-appname-uniqueid/app/assets/stylesheets/application.scss

有什么帮助吗?感谢您的宝贵时间!

附言。附带说明 - 当我运行“rake assets:precompile”然后推送到 Heroku 时,应用程序就会构建。但是,具有 css 类“fa-bars”的项目搞砸了……这是为什么呢?

谢谢!

【问题讨论】:

  • 在本地运行 rake assets:precompile 是否有效?
  • 是的,确实如此。不知道为什么它不能在 Heroku 上运行

标签: ruby-on-rails heroku assets sprockets precompile


【解决方案1】:

我在 Sprockets 3.3.3 和我们的 Rails 4.2.3 应用程序中添加了相同的问题。

我通过清理我们的 dyno 构建缓存来修复它:

heroku repo:purge_cache

请注意,您的下一次部署将需要更长的时间,因为捆绑器缓存也将被清除。

【讨论】:

  • 安装 Heroku repo 插件:heroku plugins:install https://github.com/heroku/heroku-repo.git
  • 为我工作。似乎这是 Heroku 可能想要研究的东西。
  • 很高兴我找到了解决方案,并且看到我并不孤单
【解决方案2】:

如果你使用 Bower,在 rails 5 中,取消 bower_rails.rb 中的注释

  #bower_rails.install_before_precompile = true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-24
    相关资源
    最近更新 更多