Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't seem to work on Rails 4.1 #88

Closed
arjan0307 opened this issue Apr 20, 2014 · 38 comments
Closed

Doesn't seem to work on Rails 4.1 #88

arjan0307 opened this issue Apr 20, 2014 · 38 comments
Labels

Comments

@arjan0307
Copy link

I'm working on Rails 4.1, and the gem doesn't seem to work.

The helper functions are not available (undefined_method). And I can't load the stylesheet both with require in a manifest file and with @import in a .scss file.

Is Rails 4.1 unsupported?

@rmm5t
Copy link
Collaborator

rmm5t commented Apr 20, 2014

The test matrix includes rails master (4.1) and passes. With that, I haven't spent any time with the direct combination of the two in a real app myself yet.

Sanity check: Did you remember to bundle install and restart your development environment after adding font-awesome-rails to the Gemfile.

@arjan0307
Copy link
Author

Yes, did both. Added several other gems as well, which did load.

Also ran bundle list which showed the gem.

@gogotanaka
Copy link

I'm working on Rails 4.1 too, it went well as following.

add to Gemfile
gem 'font-awesome-rails'

do bundle install

add to application.css

*= require font-awesome

@import "font-awesome";

and, restart rails server.

@rafaizidoro
Copy link

Doesn't work for me too... Rails 4.1 without SASS...
"couldn't find file 'font-awesome'"

@kwando
Copy link

kwando commented May 22, 2014

Yeah, this does not work on rails 4.1 for me either. Font files is not copied over to public/assets on precompile.

@rmm5t
Copy link
Collaborator

rmm5t commented May 22, 2014

So, we're getting some mixed reviews of whether this works on Rails 4.1 or not. I haven't yet tried it myself, and I don't know when I'll get a chancge to try the combination, but if anyone has more insight as to why some people are having problems and/or if there's something we need to fix as part of the asset wrapper, I'm all ears. In other words, pull-requests welcome.

Meanwhile, is this only an issue during asset compilation for production or are people also having trouble in development?

@licatajustin
Copy link

I was using version 4.0.3.2 in development mode. Once I updated to version 4.1.0.0 and restarted my server, the new icons weren't loading. My Gemfile showed the correct version but when inspecting my stylesheets, I could tell they were still importing from the previous version. However, when I first installed the gem, I did so on Rails 4.0 and now I'm running Rails 4.1.

To temporarily fix, I just simply copied over the assets from the newer lib to the older lib and it's works fine on Rails 4.1.

Not sure if this helps in any way, just thought I'd share my experience in case it helps resolve the issue some of you are having.

@nglx
Copy link

nglx commented May 23, 2014

That's probably related (Rails 4.1.0). I'm getting:

GET http://localhost:3000/fonts/fontawesome-webfont.woff?v=4.0.3 404 (Not Found)
GET http://localhost:3000/fonts/fontawesome-webfont.svg?v=4.0.3 404 (Not Found) 

in the browser when rails is in development mode .

@rmm5t
Copy link
Collaborator

rmm5t commented May 23, 2014

@licatajustin @managr If you're seeing some icons but not the new ones after updating to font-awesome-rails 4.1.0.0, that's a separate issue from the one reported here, and you probably have an asset caching problem with your stylesheet. See #95, and please read the debugging steps in the contribution guidelines.

@bigardone
Copy link

Same issue as @managr here with Rails 4.1.1... after updating the gem I get the following error:

        Started GET "/fonts/fontawesome-webfont.svg?v=4.0.3" for 127.0.0.1 at 2014-05-26 18:07:47 +0200

    ActionController::RoutingError (No route matches [GET] "/fonts/fontawesome-webfont.svg"):
      actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
      actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
      railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
      railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
      activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
      activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
      activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
      railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
....

And in my browser the same error commented above:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/fonts/fontawesome-webfont.woff?v=4.0.3
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular

@shinzui
Copy link

shinzui commented May 26, 2014

It's broken on rails 4.1 for me also. I get the following error:

File to import not found or unreadable: font-awesome.

I am using SCSS and have the appropriate import in my application.css.scss

@import "font-awesome";

My relevant gems:

bundle list |grep -E '(font-awesome|^rails|sprocket|sass)'
  * bootstrap-sass (3.1.1.1 a416cb8)
  * font-awesome-rails (4.1.0.0)
  * sass (3.2.19)
  * sass-rails (4.0.3)
  * sprockets (2.11.0)
  * sprockets-rails (2.1.3)

@rkyrychuk
Copy link

Had a problem

"File to import not found or unreadable: font-awesome."

Comparing with working app and downgrading gem by gem, I found, that downgrade of "bootstrap-sass" from '3.1.1.1' to '3.1.1.0' fix the problem. I had following config before and get "3.1.1.1" installed.

gem 'bootstrap-sass', '~> 3.1.1'

so, you can check if this solution works for you.
If yes, need to figure out what happens.

@justin-
Copy link

justin- commented Jun 9, 2014

I had the same problem as @rkyrychuk and downgrading bootstrap-sass to 3.1.1.0 fixed it for me as well.

@bigardone
Copy link

In my case I'm not using bootstrap-sass so I've not been able to fix it yet.

@rkyrychuk
Copy link

It can be one of the bootstrap-sass dependencies. This fix also show that it works with rails 4.1 raw dependencies. Looks like your gems as bootstrap-sass in my case require some new dependencies that cause a problem.

During debugging I had an warning from one of gem that it resolve font-awesome as font-awesome.css.erb and _font-awesome.css.erb and select one of them but his behavior will be changed in future versions of this gem. So, that can be an issue.
I had no time to debug deeper and don't know if this really cause a problem (I didn't found both files on filesystem) but if you have time, you can try to check what dependencies are changed between those working and not working gem versions and compare it to your gem list.

@acrogenesis
Copy link

I'm using it right now and works great. 4.1.1, ruby 2.1.2, font-awesome-rails 4.0.3.2

@matheusvetor
Copy link

I tried using webrick (in production mode) with ruby ​​2.1.0 with rails 4.1.1 and work fine. I'm installing ruby 1.9.3 to test again. I have 2 servers, 1.9.3 and 2.0.0 in production and not work with both.

@matheusvetor
Copy link

I tried switch the bootstrap-sass to 3.1.1.0 and still not working. In Chrome Inspector, i got 404 assets/fontawesome-webfont.woff but the assets precompiled are fontawesome-webfont-027499bf57aacf4f676ca8f2143254ac.woff. Is the same to all fontawesome assets

@dankozlowski
Copy link

Not working in Rails 4.1.1, Ruby 2.1.2, no SASS.

@rmm5t
Copy link
Collaborator

rmm5t commented Jun 20, 2014

Okay everyone. I finally found myself in a Rails 4.1 + font-awesome-rails app.

I cannot reproduce the problem that everyone is reporting. Everything works as expected in both development and production (with precompiled assets).

I'm using the latest version of bootstrap-sass, rails, font-awesome-rails

  • bootstrap-sass (3.1.1.1)
  • compass-rails (1.1.7)
  • font-awesome-rails (4.1.0.0)
  • jquery-rails (3.1.0)
  • rails (4.1.1)
  • sass (3.2.19)
  • sass-rails (4.0.3)
  • sprockets-rails (2.1.3)

I'm inclined to close this issue out unless we can get a better assessment of the underlying problem and that the problem actually exists with this gem.

@justin-
Copy link

justin- commented Jun 20, 2014

Just wanted to note that since my previous comment I have made a lot of changes to my Gemfile and now font-awesome-rails 4.1.0.0 works with the latest bootstrap-sass (3.1.1.1). I'm using the same gems and versions as @rmm5t (except compass-rails isn't installed).

@rmm5t rmm5t added the invalid label Jun 20, 2014
@bokmann
Copy link
Owner

bokmann commented Jun 20, 2014

Sorry I've been silent on this; I've been meaning to find the time to reproduce in something a little more complicated. I'm using this in a rails 4.1 app with nothing special about the development or production environments, and it 'just works'. I know the asset pipeline can be a fickle beast, but if this isn't working for you, I'd suggest auditing the details of your environment - what other gems are you using that mess with the pipeline, what order are they loaded in, etc.

I'm not suggesting the periodic chatter on this issue isn't a sign of a problem, but I am suggesting that with the fickleness of the asset pipeline, to move further on this issue (and even determine what piece of code is responsible), we'd need a minimal viable app that illustrates the issue.

@radar
Copy link

radar commented Jun 24, 2014

I can still reproduce this very easily.

git clone git://github.com/spree/spree-product-assembly
cd spree-product-assembly
bundle install
bundle exec rspec spec

The error happens for me.

It looks like the version of sass, 3.2.19, that the app is using, uses this call, which checks for files with extensions that are either sass or scss. Since font-awesome.css.erb does not have any extensions like that, it ignores it.

I don't know why it works within an application, but in those tests for that extension it definitely fails. I haven't yet been able to track down what the difference is.

@radar
Copy link

radar commented Jun 24, 2014

OK, so within an application the extensions look like this:

{"css"=>:scss,
 "css.scss"=>:scss,
 "css.sass"=>:sass,
 "css.erb"=>:scss,
 "scss.erb"=>:scss,
 "sass.erb"=>:sass,
 "css.scss.erb"=>:scss,
 "css.sass.erb"=>:sass,
 "sass"=>:sass,
 "scss"=>:scss}

But within the extension, they look like this:

{
 "sass"=>:sass,
 "scss"=>:scss}

Where are those coming from? Is that a Sprockets thing? shrug

@radar
Copy link

radar commented Jun 24, 2014

Aha, it's a sass-rails thing. If you don't require 'sass/rails', then the importer from that gem isn't loaded and the extra extensions aren't added. My guess is that this is happening due to an asset group in the applications' Gemfiles, or in the case of spree-product-assembly, it was missing that require.

Case closed?

@JDutil
Copy link

JDutil commented Jun 24, 2014

Solved the issue for me on several spree extensions.

@hcarver
Copy link

hcarver commented Jun 24, 2014

Could someone explain how @radar 's fix applies to other apps? Where do I need to be requiring sass-rails for this to be fixed? I'm seeing the same problem as @managr even on bootstrap-sass 3.1.1.0

@rmm5t
Copy link
Collaborator

rmm5t commented Jun 24, 2014

@radar Thanks for hunting this issue down and following through with additional details. Much appreciated!

Overall, is there anything this gem can do to help alleviate these problems? i.e. Do you think it is safe to close this issue out?

My guess is that this is happening due to an asset group in the applications' Gemfiles...

Everyone else, is this a possibility?

@radar
Copy link

radar commented Jun 25, 2014

@hcarver Can you grant me access to the app you're seeing this on and steps to repro? I think I can fix it.

@radar
Copy link

radar commented Jun 25, 2014

@rmm5t No problem. Happy to help :)

Yes I think it's OK to close this issue out.

The cause is that for whatever reason, sass/rails is not being required within these people's applications/code and therefore it's not getting the correct extensions setup.

The fix is to ensure that this file is required, somewhere. Usually that's done automatically through the stuff in the Gemfile, but if it's misconfigured or an app's not using a Gemfile, then you can run into this problem.

@hcarver
Copy link

hcarver commented Jun 25, 2014

@radar I can't grant you access I'm afraid.

I'm not sure this is the right fix for me - I am already requiring
gem 'sass-rails', '~> 4.0.0' in my Gemfile.

What did fix it for me was downloading to v3.1.1.0 of bootstrap-sass and removing v3.1.1.1. Seems obvious, I know, but I hadn't thought to remove the old version before. Anyway, doing that and restarting the server fixed the problem. I see that requiring sass-rails is one of the differences between those two versions of bootstrap-sass but I don't understand why requiring it in my Gemfile isn't enough to overcome that.

@radar
Copy link

radar commented Jun 26, 2014

@hcarver That's fine.

But where in your Gemfile is that line? is it within an asset group?

@hcarver
Copy link

hcarver commented Jun 26, 2014

@radar No, it's not in an asset group. From the top of my Gemfile, removing a few comments...

ruby '2.0.0'
source 'https://rubygems.org'

gem 'rails', '~>4.1.1'

gem 'pg'
gem 'enumerize', '~> 0.8.0'

gem 'sass-rails', '~> 4.0.0'
gem 'compass-rails'
gem 'bootstrap-sass', '3.1.1.0'
gem 'font_assets'
gem 'font-awesome-rails'

etc.

@radar
Copy link

radar commented Jun 27, 2014

@hcarver Seems fine. Are you certain that sass/rails is being loaded? Can you run

$EDITOR `bundle show sass-rails`

Then in lib/sass/rails.rb put a puts statement, then start your server. Do you see what that outputs?

@hcarver
Copy link

hcarver commented Jun 27, 2014

@radar Definitely.

rails s
Sass Rails loaded
...

For debugging's sake, I tried with both versions of bootstrap-sass (3.1.1.0 and 3.1.1.1). Same result both times, definitely loaded.

@rmm5t
Copy link
Collaborator

rmm5t commented Jun 29, 2014

Yes I think it's OK to close this issue out.

Great. Doing that now.

The cause is that for whatever reason, sass/rails is not being required within these people's applications/code and therefore it's not getting the correct extensions setup.

The fix is to ensure that this file is required, somewhere. Usually that's done automatically through the stuff in the Gemfile, but if it's misconfigured or an app's not using a Gemfile, then you can run into this problem.

@radar Thanks!

@rmm5t rmm5t closed this as completed Jun 29, 2014
@saddaaf
Copy link

saddaaf commented Mar 30, 2015

very simple just put .scss.erb extention to awsome fonts in stylesheets toont-awesome.min.scss.erb and font-awesome.scss.erb

@felipeands
Copy link

I was have the same problem. Because I switch the branch without restart the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests