rails bootstrap-sass资产编译错误-未定义的变量alert-padding [英] rails bootstrap-sass assets compilation error - undefined variable alert-padding

查看:102
本文介绍了rails bootstrap-sass资产编译错误-未定义的变量alert-padding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

推荐链:

  • railscast-328 (twitter bootstrap basics) refers to
  • http://www.sitepoint.com/twitter-bootstrap-less-and-sass-understanding-your-options-for-rails-3-1/ which refers to
  • https://github.com/jlong/sass-bootstrap which in turn exclaims there is a new official port of bootstrap to sass at
  • https://github.com/twbs/bootstrap-sass which is another one of the options in the twitter-bootstrap article

据报道是bootstrap-rails gem的问题: https://github.com/anjlab/bootstrap-rails/issues/91

It is reported as an issue with the bootstrap-rails gem: https://github.com/anjlab/bootstrap-rails/issues/91

宝石

gem 'sass-rails', '>= 3.2' # sass-rails needs to be higher than 3.2
gem 'bootstrap-sass', '~> 3.1.1'

已安装(在资产组的内部和外部尝试),application.css.scss包含

are installed (tried outside and inside of assets group), application.css.scss contains

@import "bootstrap";

仅。

当尝试捆绑执行耙资产:precompile 时,会出现以下错误:

When attempting bundle exec rake assets:precompile it gives this error:

rake aborted!
Undefined variable: "$alert-padding".
  (in /home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/bootstrap-sass-3.1.1.0/vendor/assets/stylesheets/bootstrap/_alerts.scss)
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/bootstrap-sass-3.1.1.0/vendor/assets/stylesheets/bootstrap/_alerts.scss:10
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/script/variable.rb:49:in `_perform'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/script/node.rb:40:in `perform'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:298:in `visit_prop'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `map'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `map'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `block in visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:100:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:7:in `visit'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/root_node.rb:20:in `render'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/engine.rb:315:in `_render'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-3.2.7/lib/sass/engine.rb:262:in `render'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.6/lib/sass/rails/template_handlers.rb:106:in `evaluate'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/tilt-1.3.7/lib/tilt/template.rb:77:in `render'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/processed_asset.rb:16:in `initialize'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/base.rb:18:in `new'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/base.rb:18:in `block in build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/base.rb:14:in `build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in `find_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/bundled_asset.rb:12:in `initialize'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/base.rb:22:in `new'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/base.rb:22:in `build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/index.rb:14:in `find_asset'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/static_compiler.rb:41:in `block in compile'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/sprockets_overrides/static_compiler.rb:29:in `compile'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/tasks/assets.rake:108:in `internal_precompile'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/turbo-sprockets-rails3-0.3.11/lib/turbo-sprockets/tasks/assets.rake:115:in `block (3 levels) in <top (required)>'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
/home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rake-10.0.4/bin/rake:33:in `<top (required)>'
/home/joe/.rbenv/versions/1.9.3-p448/bin/rake:23:in `load'
/home/joe/.rbenv/versions/1.9.3-p448/bin/rake:23:in `<main>'

我检查了 /home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/bootstrap-sass-3.1.1.0/vendor/assets/ stylesheets / bootstrap.scss 实际上确实先在 bootsrap / 目录下导入_variables.scss文件(在_alerts.scss等之前),它确实...并且在_variables.scss中定义了$ alert_padding。

I checked that /home/joe/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/bootstrap-sass-3.1.1.0/vendor/assets/stylesheets/bootstrap.scss does actually import the _variables.scss file below it in the bootsrap/ directory first (prior to _alerts.scss etc), and it does... and in _variables.scss it defines $alert_padding.

environments / production.rb 文件中,我注释掉了有关资产的所有内容,并尝试了 config.assets.initialize_o n_precompile = true 符合手册 https://github.com/twbs/bootstrap-sass

In the environments/production.rb file I commented everything about assets out, and tried just config.assets.initialize_on_precompile = true in accordance with the manual https://github.com/twbs/bootstrap-sass

  • bootstrap-sass: Undefined variable: "$baseLineHeight"
  • Proper SCSS Asset Structure in Rails
  • Using twitter bootstrap with rails assets pipeline and less
  • https://github.com/twbs/bootstrap-sass/issues/79#issuecomment-4428595
  • trying to import bootstrap via bootstrap-sass on heroku but getting an error
  • https://github.com/twbs/bootstrap-sass
  • https://github.com/anjlab/bootstrap-rails/issues/91
  • railscast 328, 329 and 268 looking for clues
  • googling about
  • modifying gem's bootstrap/bootstrap.scss to use underscore and .scss, various tinkering such as commenting out lines relating to assets in environments/production.rb, commenting in only the one in the gem's page (manual) config.assets.initialize_on_precompile = true

我将gem的内容复制到了我的资产目录,这基本上就是jlong​​的引导程序所做的。

I copied the gem's contents into my assets directory, which is essentially what jlong's bootstrap did.

它看起来并不像t application.css.scss ...它忽略了我在其中放置的内容,而是选择查看文件夹并加载这些文件。这就是为什么它首先看到alert.scss的原因。我尝试将_variables.scss的名称更改为_aavariables.scss无效

its not looking at application.css.scss... its ignoring what I put in there and electing to instead look into the folders and loading those files. Which is why it sees alerts.scss first. I tried changing the name of _variables.scss to _aavariables.scss to no avail

推荐答案

我的具体问题原来是一些代码隐藏在 application.rb ...

My specific problem turned out to be some code hiding in application.rb...

我在 config / environments / production.rb 中添加了 put config.assets.precompile.inspect 惊叹于它输出的正则表达式。然后我在代码库中搜索 config.assets.precompile,然后在application.rb中找到:

I added puts config.assets.precompile.inspect to config/environments/production.rb and marvelled at the regex it output. Then I searched the codebase for "config.assets.precompile" and lo, in application.rb, there was:

config.assets.precompile << /(^[^_\/]|\/[^_])[^\/]*$/
...
config.assets.precompile += ["*.js", "*.css", "jquery-migrate-rails.js"]

造成问题。 (我有点不解,因为我已经三遍检查了这些正则表达式,它们不应该使用_alerts.scss ...,但是要掩饰一下,并专注于删除那些行修复了这一事实)

which was causing the problem. (I'm slightly puzzled as I've triple checked those regexes and they shouldn't be picking up _alerts.scss... but lets gloss over that and focus on the fact that removing those lines fixed it)

也许这会帮助别人...

Maybe this will help someone else...

这篇关于rails bootstrap-sass资产编译错误-未定义的变量alert-padding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆