Rails + Twitter Bootstrap: File to import not found or unreadable: twitter/bootstrap
Asked Answered
P

11

18

I am trying to set up Rails app with Twitter Bootstrap (the gem twitter-bootstrap-rails), but I still cannot get over the error

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. Here's my setup: 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

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

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

Piacular answered 3/4, 2013 at 10:22 Comment(6)
did you run rails generate bootstrap:install ?Gertiegertrud
Yes, I have ran rails generate bootstrap:install, but it didn't help me.Piacular
Apologies for not getting the semantics right, I thought my answer was a solution. Anyway, couple of other things, in my app I have the file as bootstrap_and_overrides.css.less, rather than sass. I also have gem 'less-rails'. Finally, I have a require in the application.js //= require twitter/bootstrap. One thing I do not have, is @import "twitter/bootstrap";Gertiegertrud
I've tried it with SASS and LESS as well, but the same result. I noticed that if I used this version of gem: gem 'twitter-bootstrap-rails', '~> 2.0.1.0', then it's working. But there is occurring another issue - the old javascript.Piacular
This file name looks incorrect "bootstrap_and_overrides.css.sass". It should be a scss file?Pierrette
I had the same issue. It worked making the import of bootstrap from application.css.scssSasnett
R
36

we had the same problem, i just restarted the rails server and it worked

Request answered 9/9, 2013 at 11:4 Comment(1)
Sometimes, it's the small simple things that give me headaches in rails. Thanks for this reminderOak
M
6

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. The reason for this may be some varient of live reload which pre-renders several of the scss/haml type files. If that isn't the case then

  1. Read the error message and determine the scss file that is causing the error.
  2. Locate the css file that is generated along the sass file, (i.e. custom.css.scss would generate custom.css).
  3. Delete that file, refresh the page and if this files delete the entire cache found under assets/stylesheets and temp/cache)
Moulin answered 3/6, 2013 at 12:1 Comment(0)
O
3

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. Add require "twitter-bootstrap-rails to e.g config/application.rb file to explicitly require it.

Ottoottoman answered 30/8, 2013 at 19:39 Comment(0)
C
2

Downgrade the bootstrap-sass gem to v2.3.2 like so: gem 'bootstrap-sass', '2.3.2'

I had done a bundle upgrade which upgraded the bootstrap gem. This (version downgrade) fixed the problem for me.

Convey answered 25/6, 2014 at 13:35 Comment(0)
P
1

The way how I made it work was simply changing the Twitter Bootstrap gem - I used the bootstrap-sass gem, where is set up everything as is described on the Github page and I didn't find any problem with.

Piacular answered 3/4, 2013 at 12:53 Comment(0)
C
1

Did you try to compile the assets ?

    rake assets:precompile
Collar answered 23/11, 2013 at 14:38 Comment(0)
R
1

I solved this issue by adding gem 'bootstrap-sass', '3.0.2.1' in my Gemfile (per the recent docs). Make sure you run bundle install afterwards.

Regnal answered 25/11, 2013 at 18:24 Comment(0)
F
1

I found this response as I was searching for a problem with Michael Hartl's RailsTutorial.org program. I had inadvertently allowed the sprockets gem to be upgraded to 2.12.1 (it was locked in 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.

Back to learning!!

Freemasonry answered 22/4, 2014 at 19:39 Comment(0)
E
1

Nothing here worked for me. I gave up, downloaded Bootstrap itself, put the files in my assets, and included them in my CSS. That fixed it.

Eba answered 27/8, 2014 at 10:30 Comment(0)
S
0

add following gem in asset group and bundle install

gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
Scrape answered 3/4, 2013 at 12:19 Comment(1)
I've tried this already, but still the same, don't understand why the app cannot find the Bootstrap stuff. At the moment trying bootstrap-sass gem.Piacular
C
0

Try adding

gem 'sass-rails'

to your Gemfile

Christiano answered 22/11, 2013 at 21:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.