Closed dewski closed 11 years ago
I'm seeing the same issue attempting to precompile assets. Here's my bundle:
Gems included by the bundle:
* Ascii85 (1.0.1)
* actionmailer (3.2.0.rc2)
* actionpack (3.2.0.rc2)
* activeadmin (0.3.4)
* activemodel (3.2.0.rc2)
* activerecord (3.2.0.rc2)
* activeresource (3.2.0.rc2)
* activesupport (3.2.0.rc2)
* addressable (2.2.6)
* ansi (1.4.0)
* arel (3.0.0.rc1)
* bcrypt-ruby (3.0.1)
* bootstrap-sass (1.4.3)
* builder (3.0.0)
* bundler (1.1.rc.7)
* coffee-rails (3.2.0)
* coffee-script (2.2.0)
* coffee-script-source (1.2.0)
* devise (1.5.3)
* diff-lcs (1.1.3)
* erubis (2.7.0)
* execjs (1.2.13)
* factory_girl (2.1.0)
* factory_girl_rails (1.2.0)
* faraday (0.7.5)
* faraday-stack (0.1.3)
* fastercsv (1.5.4)
* formtastic (1.2.4)
* haml (3.1.4)
* has_scope (0.5.1)
* hike (1.2.1)
* i18n (0.6.0)
* inherited_resources (1.2.2)
* journey (1.0.0.rc4)
* jquery-rails (1.0.16)
* json (1.6.4)
* kaminari (0.13.0)
* kgio (2.6.0)
* mail (2.3.0)
* meta_search (1.1.1 21e9886)
* mime-types (1.17.2)
* multi_json (1.0.4)
* multipart-post (1.1.4)
* nokogiri (1.5.0)
* orm_adapter (0.0.5)
* pdf-reader (1.0.0.rc1)
* polyamorous (0.5.0)
* polyglot (0.3.3)
* rack (1.4.0)
* rack-cache (1.1)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.0.rc2)
* railties (3.2.0.rc2)
* raindrops (0.8.0)
* rake (0.9.2.2)
* rdoc (3.12)
* responders (0.6.4)
* rspec (2.7.0)
* rspec-core (2.7.1)
* rspec-expectations (2.7.0)
* rspec-mocks (2.7.0)
* rspec-rails (2.7.0)
* ruby-rc4 (0.1.3)
* sass (3.1.12)
* sass-rails (3.2.3)
* sprockets (2.1.2)
* sqlite3 (1.3.5)
* thor (0.14.6)
* tilt (1.3.3)
* treetop (1.4.10)
* turn (0.8.3)
* tzinfo (0.3.31)
* uglifier (1.0.4)
* unicorn (4.1.1)
* warden (1.1.0)
In my case, the problem seemed to stem from having config.assets.initialize_on_precompile = false
in application.rb, which I added when I was having problems deploying to Heroku.
From http://guides.rubyonrails.org/asset_pipeline.html:
For faster asset precompiles, you can partially load your application by setting config.assets.initialize_on_precompile to false in config/application.rb, though in that case templates cannot see application objects or methods. Heroku requires this to be false.
Same here. config.assets_dir
is nil and config.assets.initialize_on_precompile = false
.
bootstrap-sass (1.4.3)
sass-rails (~> 3.1)
sass (3.1.12)
sass-rails (3.2.3)
Any work-arounds?
I'm also seeing a similar error, is this a bug regression by chance?
My work around, and it's not a great one, but this is what it's like on the edge right.
In the production.rb
config.assets.initialize_on_precompile = true
Then before pushing code run:
rake assets:precompile
This will compile all your assets. Add them to your local git repository, but do not push them to your remotes.
Then deploy to heroku
git push heroku --force
With the assets in the repository, heroku won't try and compile them. The --force is needed for subsequent pushes because we are going to remove the commit with the assets before pushing again.
Now rollback your local repository
git reset --hard HEAD^
This will remove the assets you compiled and pushed to heroku so they don't mess up your development environment and clog up your remote with artifacts.
You will need to precompile and add to the repository every time you push to heroku. Make sure to use the --force or you will get an error.
I have the same issue and I've fixed setting the initialize when precompile to true (but, in theory, I don't need it). Is this a bug or a feature? ;)
I don't use heroku and I can reproduce the problem at dev machine. Using sass-rails 3.2.3
This seems to work with Heroku:
# Enable the asset pipeline
config.assets.enabled = true
config.assets.initialize_on_precompile = false
config.action_controller.assets_dir = "#{File.dirname(File.dirname(__FILE__))}/public"
indeed it does.
thanks @fauxparse!
update: this work-around causes this error in rails_admin:
Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError: rails_admin/rails_admin.css isn't precompiled
Disclaimer: your observed value of "working" may differ from mine ;)
@turadg do you have something like this in your application.rb or production.rb
config.assets.precompile += %w( rails_admin/rails_admin.css )
If you are explicitly including a css or js file besides application.css and application.js then you need to list all the js and css assets you wish to be compiled in a statement like above. I had the problem in this thread, but I also don't have any extra css or js, so maybe those don't work with this workaround. If that's the case you can try what I noted above (lots more work) it may work for you.
Yes, my guess is that those kinds of things don't happen when initialize_on_precompile
is set to false
, which I only need to do because mongo_mapper connects on initialisation (actually, I should be filing an issue about that over there).
fauxparse's workaround works for me but confirmed failing with initialize_on_precompile = false
@wleeper that worked perfectly, thanks.
@wleeper Thanks for providing the solution to my problem. To successfully deploy to Heroku, my config looked like this:
production.rb
config.assets.precompile += %w( modernizr.js rails_admin/rails_admin.js rails_admin/rails_admin.css )
application.rb
config.assets.enabled = true
config.assets.initialize_on_precompile = false
Thanks everyone. This post saved me.
So do we need to update our README? Can I close this?
I am not seeing this problem with Rails 3.2.2 and associated libraries. Not sure which one fixed it.
Closing here. If the problem persists, please I'll re-open it. Thanks!
After having some major issues over the past few weeks trying to get this to compile on Heroku, I ran into a new issue.
Previously #85, sprockets/270, and other rails related issues were the cause of those.
Now during precompiling it will error out saying
can't convert nil into String
which points toActionView::AssetPaths
on line 36. I inserted aputs config.assets_dir
which returns nil. I have a feeling sass-rails isn't passing in the correct config, but I am still investigating myself.I have attached the tracelog and my
bundle list
output to help.The output of the rake task:
Bundle list: