Ask A Question

Notifications

You’re not receiving notifications from this thread.

Issue with bootstrap sprockets in application.js

Damian Nelwep asked in Rails

Hello,

As said in the title, I get an error message when I try to access my localhost:3000.

The message is :


Sprockets::FileNotFound in Welcome#index

Showing /home/dameaw/work/five/meawinit/app/views/layouts/application.html.erb where line #8 raised:

couldn't find file 'bootstrap-sprockets' with type 'application/javascript'
Checked in these paths: 
  /home/dameaw/work/five/meawinit/app/assets/config
  /home/dameaw/work/five/meawinit/app/assets/images
  /home/dameaw/work/five/meawinit/app/assets/javascripts
  /home/dameaw/work/five/meawinit/app/assets/stylesheets
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/coffee-rails-4.2.2/lib/assets/javascripts
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/jquery-rails-4.3.5/vendor/assets/javascripts
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/toastr-rails-1.0.3/vendor/assets/javascripts
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/toastr-rails-1.0.3/vendor/assets/stylesheets
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootstrap-sass-2.3.2.2/vendor/assets/images
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootstrap-sass-2.3.2.2/vendor/assets/javascripts
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/bootstrap-sass-2.3.2.2/vendor/assets/stylesheets
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/actioncable-5.1.7/lib/assets/compiled
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/actionview-5.1.7/lib/assets/compiled
  /home/dameaw/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/turbolinks-source-5.2.0/lib/assets/javascripts

I try to get rid of '//= require bootstrap-sprockets' in the application.js file but when I do that, the style is completly broken.

Thank you for your advices in advances and have a sweet day :)

Reply

Looks like you have a version issue here.

The 3.2.0.4 gem version of bootstrap-sass specifies an import with

//= require bootstrap-sprockets

https://www.rubydoc.info/gems/bootstrap-sass/3.2.0.4

Whereas your version seems to be the 2.3.2.2. It specifies an import like this :

We have a helper that includes all available javascripts:

// Loads all Bootstrap javascripts
//= require bootstrap

You can also load individual modules, provided you sort out any related dependencies.

//= require bootstrap-scrollspy
//= require bootstrap-modal
//= require bootstrap-dropdown

https://www.rubydoc.info/gems/bootstrap-sass/2.3.2.2

You should fix your gem version in your gemfile to 2.3.2.2 and use the correct way to call the lib.

Reply

Thank you very much for the tip.

At first I tried to put "gem 'bootstrap-sass', '~> 2.3.2.2'" in the Gemfile and it turned out I got no error message but big display problems, mainly in the menu.

So I finally changed the Gemfile version to "gem 'bootstrap-sass', '~> 3.4', '>= 3.4.1'" and put back '//= require bootstrap-sprockets' in application.js and now it works perfectly :)

This is because I struggle installing some gems like social_stream. And now I'm trying to install mailboxer. Would you know a good gem for messaging/social purpose ?

Anyways thank you for your advice which has been a very good help for me :) Have a nice day mate

Reply

Yeah, even better if you're using a more recent version of bootstrap.

In terms of messaging/social purpose I would suggest to develop those features by yourself. There are not too complicated and it is better to control your features than to force yourself to use a library that will probably end up causing you more troubles than solutions.

It is based on my personal experience.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 85,376+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.