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
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:
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’
*= require bootstrap_and_overrides
*= require font-awesome
*= require_tree .
// Font Awesome
What am I missing for correct set up?
we had the same problem, i just restarted the rails server and it worked
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
- Read the error message and determine the scss file that is causing the error.
- Locate the css file that is generated along the sass file, (i.e. custom.css.scss would generate custom.css).
- Delete that file, refresh the page and if this files delete the entire cache found under assets/stylesheets and 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. Add
require "twitter-bootstrap-rails to e.g config/application.rb file to explicitly require it.
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.
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.
Did you try to compile the assets ?
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News