Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sprockets can't find bootstrap v3.3.5 while it finds v3.3.4

I am developing a Rails app (v4.2.1) which has a bootstrap installed on the vendor/assets/components/bootstrap.

Things went well until I upgraded the bootstrap from v3.3.4 to v3.3.5.

Now I see an error page that says couldn't find file 'bootstrap' with type 'text/css' .

Here is my app/assets/stylesheets/application.css:

/*
 *= require_tree .
 *= require bootstrap
 *= require fontawesome
 *= require_self
 */

If I downgrade the bootstrap to v3.3.4, this error disappears. Any suggestion?

[UPDATE]

I installed the boostrap with bower install command. The following is my .bowerrc:

{
  "directory": "vendor/assets/components"
}

I have a directory tree like this:

vendor
  + assets
    + components
      + bootstrap
        + dist
        + fonts
        + grunt
        + js
        + less
        + .bower.json
        + ...

The version of sprockets is 3.2.0. I use also sprockets-rails 2.3.2 and sprockets-es6 0.6.2.

like image 393
Tsutomu Avatar asked Jul 17 '15 02:07

Tsutomu


1 Answers

I found the cause of my question.

The bootstrap team changed the main section of bower.json as of v3.3.5. Before, it had these items:

"less/bootstrap.less",
"dist/css/bootstrap.css",
"dist/js/bootstrap.js",
"dist/fonts/glyphicons-halflings-regular.eot",
"dist/fonts/glyphicons-halflings-regular.svg",
"dist/fonts/glyphicons-halflings-regular.ttf",
"dist/fonts/glyphicons-halflings-regular.woff",
"dist/fonts/glyphicons-halflings-regular.woff2"

Now it has only two items:

"less/bootstrap.less",
"dist/js/bootstrap.js"

We can follow the relevant discussions on https://github.com/twbs/bootstrap/issues/16663. Put simply, they applied this change in accordance with the new bower specs https://github.com/bower/bower.json-spec/pull/43. Currently, Sprockets can find only files listed in the main section of bower.json. That is my problem.

So, for a workaround I changed my application.css like this:

/*
 *= require_tree .
 *= require bootstrap/dist/css/bootstrap
 *= require fontawesome
 *= require_self
 */

A fundamental solution would be a pull request to the https://github.com/rails/sprockets.

like image 143
Tsutomu Avatar answered Nov 08 '22 20:11

Tsutomu