unreadable rails not instalar found bootstrap ruby-on-rails asset-pipeline bootstrap-sass

ruby-on-rails - not - rails add bootstrap 4



error en la compilaciĆ³n de activos bootstrap-sass-variable indefinida alert-padding (3)

todos los caminos apuntan a bootstrap-sass

Cadena de referencia:

Se informa como un problema con la gema bootstrap-rails: https://github.com/anjlab/bootstrap-rails/issues/91

Creo que lo instalé correctamente

Las gemas

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

se instalan (se intentaron dentro y fuera del grupo de activos), application.css.scss contiene

@import "bootstrap";

solamente.

pero me da un error

Al intentar bundle exec rake assets:precompile , da este 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 que /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 hace realidad importe el archivo _variables.scss debajo de él en el directorio bootsrap/ (antes de _alerts.scss, etc.), y lo hace ... y en _variables.scss define $ alert_padding.

Sospecho que me estoy perdiendo algo obvio

En el archivo de environments/production.rb comenté todo sobre activos y probé solo config.assets.initialize_on_precompile = true de acuerdo con el manual https://github.com/twbs/bootstrap-sass

investigar hasta ahora

problema identificado

Copié el contenido de la gema en mi directorio de activos, que es esencialmente lo que hizo bootstrap de jlong.

no está mirando application.css.scss ... es ignorar lo que pongo allí y elegir mirar en las carpetas y cargar esos archivos. Es por eso que ve las alertas.scss primero. Intenté cambiar el nombre de _variables.scss a _aavariables.scss sin éxito


Me enfrentaba al mismo problema con Rails 4. Descubrí una solución para sobrescribir las gems . Para ello copio la gem bootstrap-sass-XXXX en la carpeta de vendors que cambiar en Gemfile para la ruta de gema

gem ''bootstrap-sass'', ''3.3.1.0'', :path => ''vendor/bootstrap-sass-X.X.X.X'' than write these 2 line @import "bootstrap/variables"; @import "bootstrap/mixins"; at top of each of file which are inside the bootstrap folder (vendor/bootstrap-sass-X.X.X.X/assets/stylesheets/bootstrap) //like for _alerts.scss // Alerts // -------------------------------------------------- @import "bootstrap/variables"; @import "bootstrap/mixins"; // Base styles // -------------------------


Mi problema específico resultó ser un código oculto en application.rb ...

como lo encontré

puts config.assets.precompile.inspect a config/environments/production.rb y me maravillé de la expresión regular que generó. Luego busqué en la base de código "config.assets.precompile" y he aquí, en application.rb, había:

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

lo que estaba causando el problema. (Estoy un poco desconcertado ya que he revisado tres veces esas expresiones regulares y no deberían estar recogiendo _alerts.scss ... pero dejemos de lado eso y nos centramos en el hecho de que eliminar esas líneas lo solucionó)

Tal vez esto ayude a alguien más ...


No sé por qué, pero para mí ayudó a poner en assets.rb esta línea

Rails.application.config.assets.precompile += [/^[-_a-zA-Z0-9]*/..*/]

Inicialmente tuve la variable Sass :: SyntaxError: Undefined: "$ alert-padding". problema con esta linea

Rails.application.config.assets.precompile += [/.*/.css/]

Pero después de cambiarlo por el primero, el problema se resolvió y todo funcionó en la producción.