繁体   English   中英

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

[英]File to import not found or unreadable: bootstrap (Bootstrap, Rails, Sass error)

这是我的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

我想出了这里的问题。

问题是我正在使用: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 ......一切都运行良好。

希望这能帮助其他一些可怜的灵魂。

我刚刚遇到了同样的问题

File to import not found or unreadable: bootstrap-sprockets

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

我有一个类似的问题,但为我解决的是:

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

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

这对我有用

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM