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

Asset pipeline broken for glyphicons on OpenShift (production deployment) #704

Closed
brevilo opened this issue Aug 29, 2014 · 3 comments
Closed

Comments

@brevilo
Copy link

brevilo commented Aug 29, 2014

When a basic Rails 4.1 application is deployed on OpenShift (production) glyphicon assets get precompiled with a digest suffix. When such an icon is used in a view, however, the related font assets are requested without that digest, causing the request to fail and hence the icons not to render properly.

As can be seen in the previous discussion leading up to this I'm pretty sure this is not caused by a flawed integration (like application.css.scss filename, missing @import or their order, //=require remnants).

Although this issue might not be caused by bootstrap-sass itself I'd like to understand what's required such that the correct asset URLs get used. Here I'm looking in particular at things like $bootstrap-sass-asset-helper and how these bits can be affected by a deployment on OpenShift.

Thanks

@dannyvanhoof
Copy link

Exactly the same issue on Heroku. Also here apparently not related to @imports or their order...

I managed to solve it by moving all my application dependent code from my bootstrap-and-overrides.css.scss directly into my application.css.scss file. Don't know though why this solves the issue

@brevilo
Copy link
Author

brevilo commented Aug 29, 2014

Thanks Danny, but my example app above doesn't sport any overrides and uses only application.css.scss itself. But it's kinda "good" to see that I'm not the only one experiencing this issue. I'm really curious what's causing this...

@brevilo
Copy link
Author

brevilo commented Sep 1, 2014

Ok, after I found that this issue also affects the font-awesome-rails gem I tried to tackle the problem from a different angle. Eventually it turned out that OpenShift doesn't explicitly set RAILS_ENV=production when precompiling the assets. While this omission still allows for generating the digest suffixes (hence my confusion about the effective environment), it prevents the app from requesting the assets with the correct URL (including the digest). Not sure why that is. I would expect either no fingerprinting/digests at all or the asset pipeline to fully work - not a mixture where one part behaves like being in the production environment but the other one doesn't! I can imagine that Heroku might do it the same way...

Anyhow, the easiest way to fix this problem on OpenShift is to provide the missing environment variable at all times (just to be sure). One can do that by logging into the gear and then creating a new file .env/user_vars/RAILS_ENV with the content production. I don't think that enabling this variable at all times should have any side-effects (does it?). It did instantly solve the problem for me.

There are obviously many others out there with the same problem, so I hope this helps!

@brevilo brevilo closed this as completed Sep 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants