Reputation: 5373
I am using Syntastic VIM plug in
All my bootstrap stuff is set up and works it's just I keep getting this error in app/assets/stylesheets/application.css.scss
|| File to import not found or unreadable: bootstrap-sprockets. Load path: ... on line 17
Line 17 is @import "bootstrap-sprockets";
My Gemfile has
gem 'rails', '4.2.0'
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.3'
my app/assets/stylesheets/application.css.scss just has
/*
* 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.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
Why does Syntastic still give me this error?
Upvotes: 2
Views: 821
Reputation: 3285
I've finally found a good solution for this issue, based on the previous solutions.
The first issue is getting the load_path
as Sprokets see it, because searching it and keeping it updated gets annoying.
rails r "
puts Rails.configuration.assets.
paths.grep(/stylesheets/).join(':')
"
Running that command generate the updated load path, to make sass checker use it, the only requirement is to export the environment variable SASS_PATH
with that value.
export SASS_PATH="$(rails r "
puts Rails.configuration.assets.
paths.grep(/stylesheets/).join(':')
")
The only problem I've found is that it does not support sprockets index files.
Upvotes: 0
Reputation: 583
If you are using RVM you can fix this problem by doing these steps
rvm gemdir
This will give you the directory of the current ruby version your application is using.
Than after that you need to find your bootstrap gem version
The brackets { } are not needed.
cd {copy and paste rvm gemdir here}/gems/
Go to your Gemfile or Gemfile.lock file and see what version of bootstrap you are using.
cd {copy and paste rvm gemdir here}/gems/{bootstrap version}
Now depending on the version you will have a vendor/assets or a /assets directory
In my case I only had the /assets
So in my situation I used this in my .vimrc
let g:syntastic_scss_sass_args="--load-path ~/.rvm/gems/ruby-2.3.0/gems/bootstrap-sass-3.3.6/assets"
This removed the error. Don't forget to reload your .vimrc
Upvotes: 0
Reputation: 21
Another option is to just to ask Syntastic to ignore this error message. In ~/.vimrc:
let g:syntastic_scss_sass_quiet_messages = {
\ "regex": 'File to import not found or unreadable', }
See :help syntastic-checker-options for more details.
Upvotes: 2
Reputation: 5059
@jan answer is the most correct answer and is the right way to go!
However, it might be a little cumbersome to actually create a local .vimrc for the current project, and then go digging in the gem's file hierarchy and find its assets.
Personally, I think that this is too much effort just to solve a simple loading confusion by Syntastic's scss checker, and which - by the way - has no effect whatsoever on the actual loading of Bootstrap.
I think most of us would agree that scss has simple rules and structure, and is very easy to debug and maintain, thus I just find it easier to disable Syntastics's scss checker altogether.
let g:syntastic_scss_checkers=['']
Upvotes: -2
Reputation: 660
Why does Syntastic still give me this error?
Syntastic gives you this error, because it doesn't know about about additional import paths set up by sprockets
. But fortunately you can configure this with the variable g:syntastic_<filetype>_<checker>_args
. So in your case you probably should set something like
let g:syntastic_scss_sass_args="--load-path path/to/bootstrap-gem/vendor/assets"
or something simular.
Extra sugar: you can use https://github.com/embear/vim-localvimrc to automagically set this variable for this project only
Upvotes: 10