简体   繁体   English

Rails + Twitter Bootstrap:导入未找到或不可读的文件:twitter / bootstrap

[英]Rails + Twitter Bootstrap: File to import not found or unreadable: twitter/bootstrap

I am trying to set up Rails app with Twitter Bootstrap (the gem twitter-bootstrap-rails ), but I still cannot get over the error 我正在尝试使用Twitter Bootstrap(gem twitter-bootstrap-rails )设置Rails应用程序,但我仍然无法克服错误

File to import not found or unreadable: twitter/bootstrap.

I found this issue on official Github of the gem, but none of solution from there have worked for me. 我在宝石的官方Github上发现了这个问题,但没有一个解决方案对我有用。 Here's my setup: Gemfile 这是我的设置: Gemfile

gem "twitter-bootstrap-rails"
gem 'font-awesome-rails'
gem 'sass-rails',   '~> 3.2.3'
group :assets do
  #gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'therubyracer', :platforms => :ruby
  gem 'uglifier', '>= 1.0.3'
end

application.css application.css

 *= require_self
 *= require bootstrap_and_overrides
 *= require font-awesome
 *= require_tree .

bootstrap_and_overrides.css.sass bootstrap_and_overrides.css.sass

@import "twitter/bootstrap";
@import "twitter/bootstrap/bootstrap";
@import "twitter/bootstrap/responsive";

// Font Awesome
@import "fontawesome";

// Glyphicons
@import "twitter/bootstrap/sprites.scss";

What am I missing for correct set up? 我错过了正确的设置?

Thanks 谢谢

我们有同样的问题,我刚刚重新启动rails服务器,它工作

If you already attempted to shut down the server and restart it, then your problem may be the cached css file that is generated from your sass file. 如果您已经尝试关闭服务器并重新启动它,那么您的问题可能是从sass文件生成的缓存的css文件。 The reason for this may be some varient of live reload which pre-renders several of the scss/haml type files. 其原因可能是一些实时重载的变化,它预先渲染了几个scss / haml类型的文件。 If that isn't the case then 如果不是这样的话

  1. Read the error message and determine the scss file that is causing the error. 阅读错误消息并确定导致错误的scss文件。
  2. Locate the css file that is generated along the sass file, (ie custom.css.scss would generate custom.css). 找到沿sass文件生成的css文件(即custom.css.scss将生成custom.css)。
  3. Delete that file, refresh the page and if this files delete the entire cache found under assets/stylesheets and temp/cache) 删除该文件,刷新页面,如果此文件删除在assets / stylesheets和temp / cache下找到的整个缓存

For some reason I had to explicitly require the gem to get it working. 出于某种原因,我必须明确要求宝石才能使它工作。 As suggested in this github issue comment to fix a similar error with bootstrap-sass, it's likely the gem is not loaded automatically. 正如在这个github问题中建议用bootstrap-sass修复类似错误的注释 ,很可能没有自动加载gem。 Add require "twitter-bootstrap-rails to eg config/application.rb file to explicitly require it. 添加require "twitter-bootstrap-rails到例如config / application.rb文件以明确要求它。

Downgrade the bootstrap-sass gem to v2.3.2 like so: gem 'bootstrap-sass', '2.3.2' 将bootstrap-sass gem降级为v2.3.2,如下所示:gem'bootstrap-sass','2.3.2'

I had done a bundle upgrade which upgraded the bootstrap gem. 我做了一个捆绑升级,升级了bootstrap gem。 This (version downgrade) fixed the problem for me. 这个(版本降级)为我解决了这个问题。

我如何使它工作的方式只是更改Twitter Bootstrap gem - 我使用了bootstrap-sass gem,在Github页面上描述了所有内容,我没有发现任何问题。

你有没有尝试编译资产?

    rake assets:precompile

I solved this issue by adding gem 'bootstrap-sass', '3.0.2.1' in my Gemfile (per the recent docs). 我通过在我的Gemfile中添加gem 'bootstrap-sass', '3.0.2.1'来解决这个问题(根据最近的文档)。 Make sure you run bundle install afterwards. 确保之后运行bundle install

I found this response as I was searching for a problem with Michael Hartl's RailsTutorial.org program. 当我在寻找Michael Hartl的RailsTutorial.org程序时,我发现了这个回应。 I had inadvertently allowed the sprockets gem to be upgraded to 2.12.1 (it was locked in Gemfile.lock). 我无意中允许sprockets gem升级到2.12.1(它被锁定在Gemfile.lock中)。 Force downgrading it to 2.11.0 fixed this error and allowed the older bootstrap-sass (2.3.2.0) gem to work correctly. 强制将其降级到2.11.0修复了此错误并允许较旧的bootstrap-sass(2.3.2.0)gem正常工作。

Back to learning!! 回到学习!!

Nothing here worked for me. 这里没有什么对我有用。 I gave up, downloaded Bootstrap itself, put the files in my assets, and included them in my CSS. 我放弃了,下载了Bootstrap本身,将文件放入我的资产中,并将它们包含在我的CSS中。 That fixed it. 修好了。

add following gem in asset group and bundle install 在资产组和捆绑安装中添加以下gem

gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"

Try adding 尝试添加

gem 'sass-rails'

to your Gemfile 到你的Gemfile

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

相关问题 要导入的文件未找到或无法读取:bootstrap(Bootstrap、Rails、Sass 错误) - File to import not found or unreadable: bootstrap (Bootstrap, Rails, Sass error) bootstrap:要导入的文件未找到或不可读 - bootstrap :File to import not found or unreadable 要导入的文件未找到或不可读:bootstrap - File to import not found or unreadable: bootstrap Ruby on Rails-导入Bootstrap错误“找不到文件或无法读取文件” - Ruby on Rails - import Bootstrap error “File not found or unreadable” 找不到要导入的文件或不可读的文件:引导链轮 - File to import not found or unreadable: bootstrap-sprockets 找不到导入文件或文件不可读:引导程序错误行#5 - File to import not found or unreadable: bootstrap error line #5 Bower,Bootstrap和sass-rails gem,错误:“找不到导入文件或不可读:bootstrap” - Bower, Bootstrap and sass-rails gem, error: “File to import not found or unreadable: bootstrap” Rails将Bootstrap从3迁移到4。找不到或不可读的导入文件:bootstrap / normalize - Rails migrating Bootstrap from 3 to 4. File to import not found or unreadable: bootstrap/normalize Bootstrap-Saas:找不到导入文件或不可读:bootstrap - Bootstrap-Saas: File to import not found or unreadable: bootstrap Rails Twitter引导轮播 - Rails Twitter Bootstrap Carousel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM