lundi 7 décembre 2015

Rails 3.2 Sprockets::FileNotFound: couldn't find file 'bootstrap-sprockets'

I am using Ruby 2.2.2 and Rails 3.2.22

Recently I have been given the task of changing our whole UI, It's an application that is several years old and has been maintained updated till rails 3.2.22. With rails 4 planned sometime next year.

I am busy trying to install bootstrap and getting the new style sheets / Javascript files loading correctly. I have removed all the old JS and CSS files and replaced them with new ones.

The assets refuse to compile though

⇒  be rake assets:precompile
/Users/Nexus/.rbenv/versions/2.2.2/bin/ruby  /Users/Nexus/.rbenv/versions/2.2.2/bin/rake assets:precompile:all  RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Sprockets::FileNotFound: couldn't find file 'bootstrap-sprockets'
   (in /Users/Nexus/work_repos/toolkit/app/assets/javascripts/application.js:9)

 Tasks: TOP => assets:precompile:primary
 (See full trace by running task with --trace)
 rake aborted!
 Command failed with status (1):    [/Users/Nexus/.rbenv/versions/2.2.2/bin/rub...]

 Tasks: TOP => assets:precompile
 (See full trace by running task with --trace)

In the assets group I have:

ruby '2.2.2'
gem 'rails', '3.2.22'
...
group :assets do 
  gem 'bootstrap-sass', '~> 3.2.0'
  gem 'sass-rails', '~> 3.2'
  gem 'coffee-rails'
  gem 'jquery-ui-rails'
  gem 'uglifier', '>= 1.3.0'
end

app/assets/stylesheets/application.css.scss

 *
 *= require_self
 *= require animate/animate.css
 *= require style
 *= require font-awesome
 */

app/assets/javasripts/application.js

//= require jquery/jquery-2.1.1.js
//= require bootstrap-sprockets
//= require metisMenu/jquery.metisMenu.js
//= require pace/pace.min.js
//= require peity/jquery.peity.min.js
//= require slimscroll/jquery.slimscroll.min.js
//= require inspinia.js

app/assets/stylesheets/style.css.scss

// Bootstrap
@import "bootstrap-sprockets";
@import "bootstrap";

// Variables, Mixins
@import "base/variables";
@import "base/mixins";

// INSPINIA Theme Elements
@import "base/typography";
@import "base/navigation";
@import "base/top_navigation";
@import "base/buttons";
@import "base/badgets_labels";
@import "base/elements";
@import "base/sidebar";
@import "base/base";
@import "base/pages";
@import "base/chat";
@import "base/metismenu";
@import "base/spinners";

// Landing page
@import "base/landing";

// RTL Support
@import "base/rtl";

// INSPINIA Skins
@import "base/skins";
@import "base/md-skin";

// Media query style
@import "base/media";

// Custom style
// Your custom style to override base style
@import "base/custom";

in the config/application.rb - (I added the config.assets.precompile lines)

config.assets.precompile += [ 'appviews.css', 'cssanimations.css', 'dashboards.css', 'forms.css', 'gallery.css', 'graphs.css', 'mailbox.css', 'miscellaneous.css', 'pages.css', 'tables.css', 'uielements.css', 'widgets.css' ]
config.assets.precompile += [ 'appviews.js', 'cssanimations.js', 'dashboards.js', 'forms.js', 'gallery.js', 'graphs.js', 'mailbox.js', 'miscellaneous.js', 'pages.js', 'tables.js', 'uielements.js', 'widgets.js', ]

# Enable the asset pipeline
config.assets.enabled = true
config.assets.initialize_on_precompile = false

# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

If I was to remove the enabling of the asset pipeline here since Rails 3 does this by default the error disappears and the web server will start. I will however get uninitialized constant Sprockets::Base on every request.

I am not sure if I even on the right track, or how I can debug this properly. I have restarted my application several times after installing the gems.

I eventually got the theme working in a rails 4 application with little stress and compiled the assets and copied them to my rails 3 application's vendor file just as a hack. But I would like to get the application now compiling properly no hacks :).

Any help will be much appreciated.

Aucun commentaire:

Enregistrer un commentaire