0

I have converted am existing rails 3.2 application to a mountable engine, but the asset pipeline is broken with the following error:

'twitter/bootstrap/bootstrap.less' wasn't found

(in /Users/developer/Projects/messaging_app/app/assets/stylesheets/messaging_phase1/bootstrap_and_overrides.css.less)

And it fails while executing the following line in bootstrap_and_overrides.css.less

@import "twitter/bootstrap/bootstrap.less";

I have verified that the twitter-bootstrap gem is installed and is loaded.

It seems that the bootstrap.less file from the gem is not loaded by the application after the application is converted to an engine.

MIdhun Krishna
  • 1,739
  • 1
  • 13
  • 31

2 Answers2

2

After adding the following lines to engine.rb, it worked.

require 'less-rails'
require 'less/rails/bootstrap'

myengine.gemspec has the following lines:

s.add_dependency 'less-rails-bootstrap'
s.add_development_dependency "therubyracer"

My app & engine specs:

  • Rails 4.2,
  • Ruby 2
  • less & less-rails 2.6.0
0

You need this in application.css (see here):

*= require bootstrap_and_overrides

but you may also try, if it is enough to just use:

*= require_tree .

And if you are using Rails 4 (which apparently you do not) you should not include the bootstrap gems in an :assets group in your gemfile (see here). This was answered here before.

Community
  • 1
  • 1
AWM
  • 1,130
  • 11
  • 23
  • Hi AWM, I already had the require statements you have mentioned. The error: 'twitter/bootstrap/bootstrap.less' wasn't found, happens when rails loads bootstrap_and_overrides into application.css and it fails to find 'twitter/bootstrap/bootstrap.less' from the gem. – MIdhun Krishna Nov 13 '13 at 03:43
  • Maybe it would be useful to post your gemfile. Do you have the lines `gem 'therubyracer'` and `gem 'less-rails'` included in you gemfile? If not, you should. You should also remove any conflicting gems like `gem 'bootstrap-sass'`. – AWM Nov 13 '13 at 10:16
  • If this does not work, please post the `=require`- and `@import`-lines of your `application.css` and the `@import`-lines of your `bootstrap_and_overrides.css.less`. – AWM Nov 13 '13 at 10:38
  • Any feedback on my suggestions? – AWM Jan 20 '14 at 15:05
  • We had a particular scenario in which a rails application was mounted as an engine into another. Twitter bootstrap was used by this engine. This scenario occurred because the engine was not loading twitter bootstrap. We fixed this by manually changing loadpath of the gem. Many thanks for your suggestions. :) – MIdhun Krishna Jan 21 '14 at 06:42