找不到或无法读取要导入的文件:bootstrap(bootstrap、Rails、Sass错误)



这是我的application.css.scss

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

我正在使用这个宝石-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

我在这里解决了这个问题。

问题是我使用的是:assets组。这在Rails4中被删除了。

http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-从第3-2类到第4-0类-文件

**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。。。一切都很顺利。

希望这能帮助其他可怜的人。

我刚刚遇到了同样的问题

File to import not found or unreadable: bootstrap-sprockets

我试着重新启动开发服务器并再次运行"rails s",效果很好!

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

  • Kill rails服务器
  • 将指令gem"bootstrap sass"、"3.3.6"添加到我的Gemfile中
  • 在服务器终端运行bundle install命令
  • 重新启动rails服务器

然而,需要注意的是,我使用的是最新版本的rails-rails 5.0.1,因此与4.2版本不同,我不必担心删除Gemfile 中的asset-do指令

这对我有效

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

最新更新