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.
Related
I'm trying to extract a couple of tasks into a gem, but cannot get the code to load in my Capfile. The code is at: https://github.com/floydj/capistrano-mysql_tables.
In my Gemfile:
gem "capistrano-mysql_tables", github: "floydj/capistrano-mysql_tables"
In my Capfile:
require "capistrano/mysql_tables"
After bundle install, it seems to be good, but running cap -T results in:
(Backtrace restricted to imported tasks)
cap aborted!
LoadError: cannot load such file -- capistrano/mysql_tables
What is wrong with the code in the gem? I've looked at other Capistrano plugins and have tried to imitate them, but it always gives this error and I've run out of things to try. It appears to be some kind of path problem, maybe. Here's what I see with gem contents:
$ bundle exec gem contents capistrano-mysql_tables
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/Gemfile
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/Gemfile.lock
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/LICENSE.txt
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/README.md
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/Rakefile
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/bin/console
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/bin/setup
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/capistrano-mysql_tables.gemspec
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano-mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano/mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano/mysql_tables/version.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/lib/capistrano/tasks/mysql_tables.rake
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/test/capistrano/mysql_tables_test.rb
/Users/username/.gem/ruby/3.0.4/bundler/gems/capistrano-mysql_tables-d1b60186a06b/test/test_helper.rb
Update:
After fixing the mistake found by #Alex, it still didn't work. However, I decided to push the gem to RubyGems, and then install via Gemfile in the standard way:
gem "capistrano-mysql_tables"
And after the standard install command, it works fine. But why does it work now? I suppose it has something to do with paths, the contents now list the following:
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/Gemfile
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/Gemfile.lock
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/LICENSE.txt
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/README.md
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/Rakefile
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/bin/console
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/bin/setup
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/capistrano-mysql_tables.gemspec
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano-mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano/mysql_tables.rb
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano/mysql_tables/version.rb
/Users/username/.gem/ruby/3.0.4/gems/capistrano-mysql_tables-0.0.2/lib/capistrano/tasks/mysql_tables.rake
I'm glad I got it working, but would like to know why it failed before? Any ideas?
I am experiencing an issue while precompiling the assets of my Rails projects.
Here is the versions of some of the gems I am using:
rails (4.2.0)
bootstrap-sass (3.3.3)
sass-rails (5.0.1)
The project is an AngularJS project sourcing the following gems from Rails Asset:
rails-assets-bootstrap-additions (0.2.3)
rails-assets-angular-bootstrap (0.11.2)
rails-assets-bootstrap-sass-official (3.3.3)
Following the README on the bootstrap-sass Github page, I renamed my app/assets/stylesheets/application.css file to application.scss and replaced its content by:
#import "bootstrap-sprockets";
#import "bootstrap";
Here is the error I get when I launch RAILS_ENV=production rake assets:precompile --trace:
** Execute assets:precompile
rake aborted!
Sass::SyntaxError: Undefined variable: "$alert-padding".
(in /home/owner/.rvm/gems/ruby-2.1.5/gems/bootstrap-sass-3.3.3/assets/stylesheets/bootstrap/_alerts.scss:10)
I looked into ClothSword's answer to this similar post, but in my case puts config.assets.precompile.inspect outputs (lambda)>, /(?:\/|\\|\A)application\.(css|js)$/], which I believe to be the default.
Would anyone have more insight on this? You can browse the source here
It looks like the problem I'm facing is that one of the gem I'm using, sprangular, is setting this precompile rule:
Rails.application.config.assets.precompile += %w( bootstrap/* )
If I comment out this rule and source my own modified version of the gem in the Gemfile, rake assets:precompile now works.
I'm not entirely sure the reason why they set a rule to precompile all of the boostrap files. Does that make sense?
I've created an issue in their Github repo to gain clarity on whether this is a bug or just me not configuring the asset pipeline properly in my app.
I will update this answer as I get clarity from the discussion over there. Feel free to make suggestions here too.
I have a rails application that I wanted to upgrade from bootstrap-sass 2 to bootstrap-sass 3
After modifying some css class name, my application worked perfectly on my machine.
I removed the #import bootstrap-responsive ( because bootstrap is natively responsive since 3.0 ) I updated my gemfile and my bundle BUT when I try to deploy my application on Heroku I have the following error :
AssetSync: using /tmp/build_68121564-cc6f-46c8-86d7-ad9ccb180ea1/config/initializers/asset_sync.rb
rake aborted!
File to import not found or unreadable: bootstrap-responsive.
Load paths:
Sass::Rails::Importer(/tmp/build_68121564-cc6f-46c8-86d7-ad9ccb180ea1/app/assets/stylesheets/developers.css.sass)
What I tried so far :
Remove gem bootstap-sass from the asset group (didn't work )
I tried the rake tmp:clear command (didn't work either )
Bundle updated and bundle installed everything again ( still not working )
What should I do ?
The problem is clearly due to some temp files but even after cleaning them I can't push my app on heroku.
Solved
I just had a #import bootstrap-responsive in another .css.scss file im my repo.
It seems a lot of people are having similar problems. I consulted this thread, this, and this article, among others. I have found a lot of topics concerning these issues, but the posted solutions have been unable to find a definitive fix. I am currently running rails 3.2.8 with ruby 1.9.2, and Heroku stack cedar.
I am having two major, related issues:
1) My projects are pushing some assets - not all - to heroku.
Per suggestions in other threads, when I place:
config.assets.initialize_on_precompile = false
in my /config/application.rb,
config.serve_static_assets = true
config.assets.precompile += %w( *.js )
in /config/environments/production.rb, and
gem 'rails_12factor', group: :production
in my gemfile, the push will precompile successfully, however the application.js file is empty on Heroku:
2) Precompiling before a push successfully puts JS on Heroku, but it is no longer recognized.
After removing
config.assets.precompile += %w( *.js )
from /config/production.rb, and running
RAILS_ENV=production bundle exec rake assets:precompile
committing and pushing results with index.html.erb not recognizing JS despite application.js present & non-empty as shown below:
I feel as if I have tried all combinations of these solutions to no avail. I have not yet updated the applications to Rails 4, is this a good idea to do at this time?
Any other suggestions where to go from here?
Oddly, in another Rails 3.2 app of mine, I get a similar error only the first time I visit
Once the page loads, simply hitting refresh loads all content and the errors go away. This app has none of the attempted solutions above in its codebase.
I had the same problem, what solved it for me was specifying my ruby version in the gemfile.
ruby '1.9.3'
No answer, but this may help. I precompile using the options below, which means only MD5 versions are created, this helped me fix a few issues.
rake -v --trace assets:precompile:primary RAILS_ENV=production
I also always do this before a precompile:
rake assets:clean
Also, double-check the exact MD5'd name, both in the html and the name of the file in heroku.
Same happened to me. When I updated the Rails version from 3.2.8 to 3.2.11 it Worked!
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.