【问题标题】:File to import not found or unreadable: bootstrap (Bootstrap, Rails, Sass error)找不到或无法读取要导入的文件:引导程序(引导程序、Rails、Sass 错误)
【发布时间】:2014-10-21 19:55:40
【问题描述】:

这是我的application.css.scss

/*
 *= require_self
 *= require_tree .
 *= require social-share-button
 */

我正在使用这个 gem - https://github.com/twbs/bootstrap-sass

根据说明,这是我 Gemfile 中的 :assets 组:

group :assets do
  gem 'sass-rails', '~> 4.0.3'
  gem 'uglifier', '>= 1.3.0'
  gem 'coffee-rails', '~> 4.0.0'
  gem "font-awesome-rails"
  gem 'bootstrap-sass', '~> 3.2.0'
  gem 'autoprefixer-rails'
end

我创建了一个名为 bootstrap_and_overrides.css.scss 的文件,其中包含:

@import "bootstrap-sprockets";
@import "bootstrap";
@import "bootstrap-responsive";
@import "font-awesome";

这是错误:

Sass::SyntaxError at /
File to import not found or unreadable: bootstrap-sprockets.
/app/assets/stylesheets/bootstrap_and_overrides.css.scss:1)

这是我的application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require bootstrap-sprockets
//= require social-share-button
//= require_tree .

我已多次重新启动服务器,并从隐身窗口查看我的应用程序。

我正在使用 Rails 4.1.1 和 Ruby 2.1.1。

有什么建议吗?

更新 1:

不管怎样,这就是我的app/assets/stylesheets/ 的样子:

$ ls
application.css.scss            bootstrap.css               font-awesome.min.css
bootstrap-social.css            bootstrap.min.css           locations.css.scss
bootstrap-theme.css         bootstrap_and_overrides.css.scss    main.css
bootstrap-theme.min.css         font-awesome.css            posts.css.scss

【问题讨论】:

  • 此问题与您要导入的任何 sass 文件有关,而不仅仅是引导程序。

标签: css ruby-on-rails twitter-bootstrap ruby-on-rails-4 sass


【解决方案1】:

我在这里发现了问题。

问题是我正在使用:assets 组。这已在 Rails 4 中删除。

http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-3-2-to-rails-4-0-gemfile

**4.2 Gemfile**
Rails 4.0 removed the assets group from Gemfile. You'd need to remove that line from your Gemfile when upgrading. 

一旦我将它们从资产组中取出,删除我的 Gemfile.lock 并运行 bundle install...一切都运行良好。

希望这可以帮助其他一些可怜的人。

【讨论】:

    【解决方案2】:

    这对我有用

    gem 'bootstrap-sass', :git => 'https://github.com/twbs/bootstrap-sass.git', :branch => 'next'
    

    【讨论】:

      【解决方案3】:

      我刚遇到同样的问题

      File to import not found or unreadable: bootstrap-sprockets
      

      我尝试重新启动开发服务器并再次运行“rails s”,它运行良好!

      【讨论】:

        【解决方案4】:

        我遇到了类似的问题,但为我解决的问题是:

        • 杀死rails服务器
        • 将指令 gem 'bootstrap-sass', '3.3.6' 添加到我的 Gemfile 中
        • 在服务器终端运行bundle install命令
        • 重启 Rails 服务器

        但是,请注意,我使用的是最新版本的 rails - Rails 5.0.1,因此与 4.2 版不同,我不必担心删除 Gemfile 中的资产 do 指令

        【讨论】:

        • 我对这个解决方案感到困惑。 Bootstrap 3 不是 bootstrap-sass gem,而 bootstrap gem 是 Bootstrap 4 的吗?对早期的 gem 有依赖似乎很奇怪,还是我只是错过了什么?
        猜你喜欢
        • 1970-01-01
        • 2014-12-19
        • 2011-08-25
        • 1970-01-01
        • 1970-01-01
        • 2014-10-30
        • 2021-12-08
        • 2015-08-03
        • 1970-01-01
        相关资源
        最近更新 更多