I am using Syntastic VIM plug in
我正在使用Syntastic VIM插件
All my bootstrap stuff is set up and works it's just I keep getting this error in app/assets/stylesheets/application.css.scss
我的所有bootstrap东西都已设置并运行它只是我在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";
第17行是@import“bootstrap-sprockets”;
My Gemfile has
我的Gemfile有
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
我的app / assets / stylesheets / application.css.scss就是这样
/*
* 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?
为什么Syntastic仍然给我这个错误?
4 个解决方案
#1
10
Why does Syntastic still give me this error?
为什么Syntastic仍然给我这个错误?
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
Syntastic给出了这个错误,因为它不知道sprockets设置的其他导入路径。但幸运的是,您可以使用变量g:syntastic_
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
额外的糖:您可以使用https://github.com/embear/vim-localvimrc自动为此项目设置此变量
#2
1
Another option is to just to ask Syntastic to ignore this error message. In ~/.vimrc:
另一个选择是让Syntastic忽略此错误消息。在〜/ .vimrc中:
let g:syntastic_scss_sass_quiet_messages = {
\ "regex": 'File to import not found or unreadable', }
See :help syntastic-checker-options for more details.
有关更多详细信息,请参阅:help syntastic-checker-options。
#3
0
If you are using RVM you can fix this problem by doing these steps
如果您使用的是RVM,则可以通过执行这些步骤来解决此问题
rvm gemdir
This will give you the directory of the current ruby version your application is using.
这将为您提供应用程序正在使用的当前ruby版本的目录。
Than after that you need to find your bootstrap gem version
之后你需要找到你的bootstrap gem版本
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.
转到Gemfile或Gemfile.lock文件,查看您正在使用的引导程序版本。
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
现在,根据版本,您将拥有供应商/资产或/ assets目录
In my case I only had the /assets
在我的情况下,我只有/资产
So in my situation I used this in my .vimrc
所以在我的情况下,我在.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
这消除了错误。不要忘记重新加载.vimrc
#4
-2
@jan answer is the most correct answer and is the right way to go!
@jan答案是最正确的答案,是正确的方法!
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.
但是,为当前项目实际创建本地.vimrc可能有点麻烦,然后深入挖掘gem的文件层次结构并查找其资产。
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.
就个人而言,我认为这只是为了解决Syntastic的scss检查器的简单加载混淆而付出太多努力,顺便说一下,它对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.
我想我们大多数人都同意scss具有简单的规则和结构,并且非常容易调试和维护,因此我发现更容易完全禁用Syntastics的scss检查器。
let g:syntastic_scss_checkers=['']
#1
10
Why does Syntastic still give me this error?
为什么Syntastic仍然给我这个错误?
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
Syntastic给出了这个错误,因为它不知道sprockets设置的其他导入路径。但幸运的是,您可以使用变量g:syntastic_
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
额外的糖:您可以使用https://github.com/embear/vim-localvimrc自动为此项目设置此变量
#2
1
Another option is to just to ask Syntastic to ignore this error message. In ~/.vimrc:
另一个选择是让Syntastic忽略此错误消息。在〜/ .vimrc中:
let g:syntastic_scss_sass_quiet_messages = {
\ "regex": 'File to import not found or unreadable', }
See :help syntastic-checker-options for more details.
有关更多详细信息,请参阅:help syntastic-checker-options。
#3
0
If you are using RVM you can fix this problem by doing these steps
如果您使用的是RVM,则可以通过执行这些步骤来解决此问题
rvm gemdir
This will give you the directory of the current ruby version your application is using.
这将为您提供应用程序正在使用的当前ruby版本的目录。
Than after that you need to find your bootstrap gem version
之后你需要找到你的bootstrap gem版本
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.
转到Gemfile或Gemfile.lock文件,查看您正在使用的引导程序版本。
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
现在,根据版本,您将拥有供应商/资产或/ assets目录
In my case I only had the /assets
在我的情况下,我只有/资产
So in my situation I used this in my .vimrc
所以在我的情况下,我在.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
这消除了错误。不要忘记重新加载.vimrc
#4
-2
@jan answer is the most correct answer and is the right way to go!
@jan答案是最正确的答案,是正确的方法!
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.
但是,为当前项目实际创建本地.vimrc可能有点麻烦,然后深入挖掘gem的文件层次结构并查找其资产。
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.
就个人而言,我认为这只是为了解决Syntastic的scss检查器的简单加载混淆而付出太多努力,顺便说一下,它对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.
我想我们大多数人都同意scss具有简单的规则和结构,并且非常容易调试和维护,因此我发现更容易完全禁用Syntastics的scss检查器。
let g:syntastic_scss_checkers=['']