compass-rails gem not being run in heroku? - ruby-on-rails

My gemfile recently upgraded my compass-rails gem. I started getting the following error (production on heroku only - works fine locally), and have been stuck on it for hours:
Completed 500 Internal Server Error in 14284ms
2012-09-03T20:53:25+00:00 app[web.1]:
2012-09-03T20:53:25+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: compass/css3.
2012-09-03T20:53:25+00:00 app[web.1]: Load path: Sass::Rails::Importer(/app/app/assets/stylesheets/application.css.scss)
I think part of the problem must lie within the fact the /app/app/ is appearing in the path here - but I dont understand why. When I change the compass config below, to "assets/stylesheets" I still see /app/app/ in the trace error.
production.rb:
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
compass.rb
# Require any additional compass plugins here.
project_type = :rails
sass_dir = "app/assets/stylesheets"
Gemfile
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier', '1.2.4'
gem 'yui-compressor', '0.9.6'
gem 'compass-rails'
end
In my application.css.scss file:
#import "compass/css3";
I've been trying every solution I can find without any luck so far
Anything sticking out?

Yes, moving compass-rails out of :assets works but is not an ideal solution.
Checking through the output from the push to heroku I found
Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
But it is compiling locally with
RAILS_ENV=production rake assets:precompile
The solution is not to instantiate the DB when precompiling assets. In config/application.rb:
config.assets.initialize_on_precompile = false
See this issue in the compass-rails project:
https://github.com/Compass/compass-rails/issues/19

I upgraded my rails to 3.2+ and ended up moving compass-rails outside of the assets group to make it work. I dont really understand why it works, but it seemed to do the trick.

Related

Sprockets::FileNotFound: couldn't find file '../../fonts/bootstrap/glyphicons-halflings-regular.eot'

Tonight I got a strange new error when trying to push to Heroku. Normally pushing to Heroku works fine, but for some reason tonight apparently a glyphicon is missing from bootstrap-sass project and Heroku thus fails to accept a push. Here's the error Heroku gives upon git push heroku master:
Running: rake assets:precompile
I, [2014-06-17T02:59:50.058577 #768] INFO -- : Writing /tmp/build_f0c4c8f6-f9ab-40b7-9346-9eb892ea1990/public/assets/karen-1-1a16815583cabbc3e2b1afa7877ecb2f.png
I, [2014-06-17T02:59:50.063553 #768] INFO -- : Writing /tmp/build_f0c4c8f6-f9ab-40b7-9346-9eb892ea1990/public/assets/south-c-1-52ab385056b021aa07ad6ae253eb6054.png
I, [2014-06-17T02:59:59.186515 #768] INFO -- : Writing /tmp/build_f0c4c8f6-f9ab-40b7-9346-9eb892ea1990/public/assets/application-91b0b1a3925fb425e8b51c103f7009af.js
rake aborted!
Sprockets::FileNotFound: couldn't find file '../../fonts/bootstrap/glyphicons-halflings-regular.eot'
(in /tmp/build_f0c4c8f6-f9ab-40b7-9346-9eb892ea1990/app/assets/stylesheets/application.css.scss:1)
I have all assets to precompile, in config/application.rb I have config.serve_static_assets = true.
In app/assets/stylesheets/application.css.scss I'm making sure to import bootstrap: #import "bootstrap";
My gem file:
gem 'bootstrap-sass', github: 'twbs/bootstrap-sass'
gem 'bootstrap-sass-extras'
Is this an issue with the bootstrap-sass gem, as I see someone else recently had the same issue with no solution: https://github.com/twbs/bootstrap-sass/issues/592
A temporary solution that at least lets me push to Heroku successfully and have my assets precompiled is to remove github: 'twbs/bootstrap-sass' from the Gemfile where bootstrap-sass is imported and just have the line gem 'bootstrap-sass'. Hopefully this bug will be fixed soon at the Github project.
Edit 5 months later: this bug was fixed a few nights after this question was asked.

Bootstrap-sass asset compilation on Heroku deployment

I am currently working on a Rails application that uses the bootstrap-sass gem to help style some of my front end views. When running locally, I have no problem browsing the views. After Heroku deployment, I receive the following error:
ActionController::RoutingError (No route matches [GET] "/assets/bootstrap-responsive.css")
Here is a snippet of my application.rb file:
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.assets.compile = true
config.assets.initialize_on_precompile = false
Any thoughts as to how to get bootstrap-sass working on a Heroku deployment with asset pre-compilation?
Did you install the 12factor gem? You'll need that with Rails
gem 'rails_12factor', group: :production
https://devcenter.heroku.com/articles/getting-started-with-rails4#heroku-gems
I had my bootstrap import statements in my application.css file. By moving to a bootstrap_and_overrides.css.scss file, my problem was solved.
This post helped: Getting bootstrap-sass bootstrap CSS into production on Heroku

zurb-foundation gem not added to asset path in existing Rails 3.2 application

I have an existing Rails 3.2.14 application that I am trying to add zurb-foundation to. I have added the zurb-foundation gem and run the installation generator.
My problem is that, whenever I try to load a page, I get this error:
couldn't find file 'foundation'
when Sprockets hits the
//= require foundation
line in application.js
The problem appears to be that the directory with the assets from the zurb-foundation gem are not being added to the load path. In contrast, I have an application that I generated more recently, including zurb-foundation from the beginning, and #asset_paths.asset_environment.paths includes the following
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.0/js"
which are not included in the asset load path in the app I am updating. Instead, I am getting (with p #asset_paths.asset_environment.paths in the better_errors diagnostic window)
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts"
interestingly, if I run the console in development mode and look at Rails.application.config.assets.path, it includes:
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/images",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-ui-rails-4.0.4/app/assets/stylesheets",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0.4/vendor/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/scss",
"/usr/local/var/rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/zurb-foundation-4.3.1/js"
and that DOES include the zurb-foundation asset paths.
I have included gem 'zurb-foundation' in the assets group, in the development group, and outside any group. I am using zurb-foundation-4.3.1 in the new app.
My Gemfile assets group is:
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'compass-rails'
gem 'zurb-foundation'
end
This problem seems similar to Sprockets::FileNotFound with ZURB Foundation, although Jurriaan did not mention the asset load path.
Any idea what I could be missing?
Thanks!
Have you tried restarting the webserver?
Update:
You said it runs fine in development, Have you tried to rake assets:clean and rake assets:precompile?
It was a problem with a gem that was preventing foundation's entries being added to the load_path. The gem involved was mongomapper-versioned.
By not loading that gem, the problem resolved. By adding the gem back, the problem recurs.
That gem has not had any activity for two years. I guess it's time to find something else.

icon-globe not found after update gem twitter-bootstrap-rails

I'm using twitter-bootstrap-rails gem. Last night I updated my gems, and tried using the icon-globe but all i got was an empty space.
here are my Gemfile:
gem 'jquery-rails'
gem 'therubyracer'
gem 'mongoid'
gem 'bson_ext'
gem 'bson'
gem 'mongo'
gem 'devise'
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
I tried rake tmp:clearbut this didn't worked too
I just ran into this the other day as well. I have my Rails servers setup so that I can run multiple Rails apps on the same server under their own suburi. Apparently the asset-path helper in the bootstrap_and_overrides.css.less is not including the relative path for the sprites and instead points the background-image url to /assets instead of /suburi/assets.
Following what I found here: https://github.com/rails/rails/issues/3365 I was able to gather that I needed to do the folllowing when precompiling assets:
RAILS_RELATIVE_URL_ROOT="/suburi" rake assets:precompile
This sets the relative root within the environment when you precompile and everything then works as it should.
The thing that really threw me for a loop was that in development everything worked just fine. As soon as I pushed it to the production server the icons stopped showing up. I kept thinking there was an issue with my server or my code. All along it was just the asset-path helper not including the suburi when I precompiled my assets.
Just set your full suburi path in the RAILS_RELATIVE_URL_ROOT environment variable before running the precompile and it will work.
Update: You can set this variable in the config/application.rb file by adding
config.action_controller.relative_url_root = '/suburi'
This would be the best option as it would not require extra typing when deploying.
You can read about it here:
http://guides.rubyonrails.org/configuring.html#configuring-action-controller
did you try:
bundle exec rake assets:precompile
on your production environment?

'sass' in a non thread-safe way

I'm getting these warnings when trying to use sass in Rails 3.1 rc1.
WARN: tilt autoloading 'sass' in a non thread-safe way; explicit require 'sass' suggested.
WARN: tilt autoloading 'sass/plugin' in a non thread-safe way; explicit require 'sass/plugin' suggested.
This is my Gemfile.
gem "rails", "~> 3.1.0.rc1"
gem "haml"
gem "sass"
I've tried to create a file called sass.rb inside the config/initializers containing this code.
require "sass"
Changing the Gemfile to this.
gem "rails", "~> 3.1.0.rc1"
gem "haml"
gem "sass", require: false
But the warnings remains.
Anyone knows how to solve it?
I found the code that is printing the warnings, if that is to any help.
have you tried doing this in Gemfile?
gem "sass", :require => 'sass'
this is an explicit call, without using initializers. by the way consider that you're using a rc1 release.
I had the same problem, and was able to solve it by compiling assets locally before pushing to Heroku as mentioned in the article Rails 3.1+ Asset Pipeline on Heroku Cedar
RAILS_ENV=production bundle exec rake assets:precompile
I also tried Itecedors suggestion which also worked:
While precompiling assets, in Rails 3.1.1 and up, you can prevent initializing
your application and connecting to the database by ensuring that the following
line is in your > config/application.rb:
config.assets.initialize_on_precompile = false
On Heroku I was getting this same error and googling did not help me find the problem, so I thought I would add what I found to this questions since it comes up first when searching.
The problem was NOT this error, it was a smaller error while pushing the code up to Heroku. After the gems are listed these lines got me on the path to the answer:
Running: rake assets:precompile
rake aborted!
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
I had just been configuring Redis on Heroku so I knew that the problem had to be something related to those changes. At that URL I found this:
While precompiling assets, in Rails 3.1.1 and up, you can prevent initializing your
application and connecting to the database by ensuring that the following line is in your > config/application.rb:
config.assets.initialize_on_precompile = false
Adding the on_precompile = false line fixed all the errors, including the original one in this question.

Resources