font-awesome-rails: Rails Engine - File to import not found or unreadable: font-awesome

I did a super simple rails app and used font-awesome with no problem. Expanding this to do the same steps in a rails engine produces the following error. I am guessing this will be a simple fix, but I haven’t been able to find one.

File to import not found or unreadable: font-awesome

Steps to generate the engine and setup font-awesome…

create the basic engine with one model class for testing

rails plugin new testeng --full --mountable 
cd testeng
bundle install
rails g scaffold book title:string desc:string
rake db:migrate

add in font-awesome

  • edit testeng.gemspec and add sass-rails and font-awesome gems after the rails gem is included
  s.add_dependency 'sass-rails', '~> 4.0.3'
  s.add_dependency 'font-awesome-rails'
  • rename application.css to application.css.scss
cd app/assets/stylesheets/testeng/
mv application.css application.css.scss
  • edit app/assets/stylesheets/testeng/application.css.scss and append import statement at end of file.
@import 'font-awesome';
  • edit app/views/testeng/books/index.html.erb and use some font-awesome icons
<h1>Listing books</h1>

<%= link_to content_tag(:i, '', :class => "fa fa-plus-circle"), new_book_path  %>

start rails server

cd <root-app-path>
bundle install
cd test/dummy
bundle install
rails s

Test in browser

http://localhost:3000/testeng/books

Get ERROR

File to import not found or unreadable: font-awesome

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 3
  • Comments: 25

Commits related to this issue

Most upvoted comments

Restart app.

using @import 'font-awesome.css' in SCSS or SASS has solved problem.

For me using require 'sass-rails' in engine.rb has solved problem.

Okay. For everyone building Rails Engines that depend on font-awesome-rails, I think you just need to make sure that you manually require "font-awesome-rails" somewhere in your engine.

For example, I just submitted a pull-request to @elrayle’s test engine: https://github.com/elrayle/testeng/pull/1

Here’s an article that helps explain why this might be necessary: https://bibwild.wordpress.com/2013/02/27/gem-depends-on-rails-engine-gem-gotcha-need-explicit-require/

Here’s a StackOverflow answer that helps confirm this: http://stackoverflow.com/a/5850503/8985

I did a quick test myself, and things seemed to work as expected afterwards. If someone could chime in and confirm that this also works for their own engine, I’ll go ahead and close out this issue after adding something to the README too.

After running gem update, I’ve the same issue. use @import 'font-awesome.css'solve my problem.

File to import not found or unreadable: font-awesome

here is the changes,is this sprockets related?

-    coffee-script-source (1.9.1.1)
+    coffee-script-source (1.9.1)

-    connection_pool (2.2.0)
+    connection_pool (2.1.3)

-    execjs (2.5.2)
+    execjs (2.5.1)

+    hike (1.2.3)

-    jbuilder (2.2.13)
+    jbuilder (2.2.12)

-    sprockets (3.0.0)
+    sprockets (2.12.3)
+      hike (~> 1.2)
+      multi_json (~> 1.0)
+      tilt (~> 1.1, != 1.3.0)

@rmm5t And of course you mean require 'font-awesome-sass', not require 'font-awesome-rails'

Requiring this at the top of my engine.rb did the trick (along with all the other dependancies; I’d forgotten)

For anyone still coming across this error and not using engines, I had to also upgrade to sass-rails 5.0.4 and bootstrap-sass 3.3.6.

I seem to have moved on by using @import ‘font-awesome.css’ (since there doesn’t seem to be a font-awesome.scss)