codeObserver
codeObserver

Reputation: 6647

Heroku doesnt precompile assets for rails4

The documentation here says that heroku with pre-compile assets during deployement in Rails4.

However , I dont see the precompile assets message.

     Using thin (1.6.1)
       Using twitter-bootstrap-rails (2.2.8)
       Using uglifier (2.3.1)
       Using will_paginate (3.0.4)
       Your bundle is complete! It was installed into ./vendor/bundle
       Bundle completed (1.37s)
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
       Detected manifest file, assuming assets were compiled locally
-----> Discovering process types
       Procfile declares types -> (none)
       Default types for Ruby  -> console, rake, web, worker

I am facing issues with bootstrap in my app, where the nav bar wont load properly + some other nuances and I think its the asset precompile issue.

I am using Rails4, Ruby2.0

I have assets enabled in application.rb

config.assets.enabled = true

Precompiling manually did not help

heroku run rake assets:precompile

Upvotes: 8

Views: 2014

Answers (4)

irmiller22
irmiller22

Reputation: 182

I struggled with the asset pipeline for a while. There seems to be a bit of confusion as to how the asset pipeline works among newer Rubyists. In my experience, this is my workflow to the asset pipeline for Heroku.

  • Make sure that assets work locally on localhost (required for Heroku)
  • Delete the public/assets folder in the Rails directory with rm -rf ./public/assets
  • Make a new assets directory with mkdir public/assets
  • Run the rake assets:precompile command
  • You should see a list of assets being precompiled in your command line
  • Once assets are precompiled, you should commit the changes via the following commands: git add -A then git commit -am "commit message goes here"
  • Finally, push to heroku via git push heroku master

NOTE: This bears repeating -- make sure your assets work normally on localhost before pushing to Heroku.

Upvotes: 5

gsumk
gsumk

Reputation: 891

The message Detected manifest file, assuming assets were compiled locally is shown if there is .sprockets-manifest-*.json or manifest-*.json in public assets. So either removing individual file or whole public/assets works.

The source code for buildpack is here

Upvotes: 0

hsidar
hsidar

Reputation: 261

Had this same problem. I had precompiled locally for some reason and then pushed to Heroku.

Saw Heroku give the line "Detected manifest file, assuming assets were compiled locally" which made me realize it wasn't precompiling all the things.

When I did a "git add ." and committed, I saw that it was adding a bunch of public files. Pushing that to Heroku got it to work. So I had to precompile and git add everytime, basically doing Heroku's work for it and making a mess in my public folder. It got the job done, but was a poor fix.

I looked for the "manifest" that heroku mentioned and eventually found a ".sprockets-manifest..." file in the public directory.

Deleted that and Heroku was once again my friend.

Found this question as part of my research so I thought I'd share what I found in case anyone else sees this, or has any elaborational thoughts.

Now I have to go and see if .sprockets-manifest was important to anything else ....

Upvotes: 20

codeObserver
codeObserver

Reputation: 6647

Deleting the public/assets folder helped. Also I ran heroku run rake assets:clean.

After that I could see:
----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile

The navbar loads fine now !

Upvotes: 3

Related Questions