1

I've added bootstrap-sass to my gemfile. I've followed the instructions here https://github.com/twbs/bootstrap-sass. Modifications have been made to the javascript/application.js.scss and stylesheet/application.css.scss files per the above link.

When I try to view a new controller, I get this:

Sass::SyntaxError in Test#index Showing /Users/myuser/Rails/myproject/app/views/layouts/application.html.erb where line #5 raised:

File to import not found or unreadable: bootstrap-sprockets.

*/ @import "bootstrap-sprockets"; @import "bootstrap";

I haven't added any bootstrap code to the Rails app yet. It's a new Rails app with only the above modifications and one new controller.

I did run bundle install but it seemed to not install anything. The output was this:

Bundle complete! 13 Gemfile dependencies, 56 gems now installed. Use bundle show [gemname] to see where a bundled gem is installed.

along with a bunch of Usings. I did see these entries:

Using bootstrap-sass 3.3.5.1
Using bootstrap-sass 0.0.2

Any idea why I'm getting the above error?

McVenco
  • 1,011
  • 1
  • 17
  • 30
4thSpace
  • 43,672
  • 97
  • 296
  • 475
  • `javascript/application.js.scss` is not a CSS file, it's javascript. You only change your CSS file extension to use SCSS. – vanburen Nov 21 '15 at 16:53
  • You may restart your server like this suggestion http://stackoverflow.com/questions/26135126/sasssyntaxerror-file-to-import-not-found-or-unreadable-bootstrap-sprockets – Hieu Pham Nov 21 '15 at 16:53
  • Do you have the gem 'sass-rails' in your gemfile? – Elvn Nov 21 '15 at 17:07
  • I've renamed the files. Restarted the server. Yes - sass-rails is in the gem file. Still no change. – 4thSpace Nov 21 '15 at 17:19

1 Answers1

1

you got your files a bit wrong.

make sure you have 'app/assets/javascripts/application.js with the following content

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require_tree .

and 'app/assets/stylesheets/application.scss' with following

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 */
@import "bootstrap-sprockets";
@import "bootstrap";

pay attention to file names and extensions

AndreiMotinga
  • 1,024
  • 17
  • 24
  • I have the same extensions now. I moved "require bootstrap-sprockets" above "require_tree ." but still no change. I get the same error. – 4thSpace Nov 21 '15 at 17:19
  • since its a new app, I assume shouldn't have any other files. make sure you have two of the files exactly as above and then don't forget to restart the server – AndreiMotinga Nov 21 '15 at 17:24
  • I have a few more requires in my files than you. There is one project this is working. It's also a new project. There is no difference with the files. I do remember after running bundle install that bootstrap-sass displayed an ascii ghost and you could tell it installed. With this other project, that didn't happen. bootstrap-sass does show as installed in my local gems. – 4thSpace Nov 21 '15 at 17:42
  • 1 `rails new foo` 2. add to gemfile `gem 'bootstrap-sass', '~> 3.3.5'` 3. `bundle` 4. `mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss` 5. remove from application.scss `*= require_tree . *= require_self` 5. add to application.scss `@import "bootstrap-sprockets"; @import "bootstrap";` 6. put right befor tree in application js `//= require bootstrap-sprockets` may be you still have '=* require ' in scss file – AndreiMotinga Nov 21 '15 at 17:46
  • may be you still have '=* require ' in scss file ? you shouldn't – AndreiMotinga Nov 21 '15 at 17:58
  • I found the issue. It was a misspelling on the bootstrap-sass gem in the gem file. Although I had to delete the folder and start over before anything would work. Had to even create the app with a completely new name. Go ahead and start with the gazillion down votes. – 4thSpace Nov 21 '15 at 18:19
  • it's unlikely to be a misspelling, would've been totally different error. and `bundle install` wouldn't succeed – AndreiMotinga Nov 21 '15 at 18:28