Detected manifest file, assuming assets were compiled locally - ruby-on-rails

I am trying to push to Heroku and my deploy shows as successful but when I look at the app it says:
Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.
When I look at the log the only thing I could find that might be causeing the problem is
Detected manifest file, assuming assets were compiled locally
I have followed the steps from the heroku docs to precompile my assets with rake assets:precompile before pushing to heroku but in the log I never get the message:
-----> Preparing Rails asset pipeline
I am not sure what I am missing?
Thanks

try running rake assets:clobber before you deploy

Related

Successfully compiled resources are not displayed in the production environment?

After compiling assets in production, old assets are displayed instead of new assets. Moreover, the compilation was successful and the file with the new assets is present on the server. I tried running rake assets:clean, it didn't help.
What could be the problem and how can it be solved?
I tried running rake assets:clean, it didn't help.

Navbar from rails application disappears when deploying to Heroku

I have been building a Rails application that I am deploying to Heroku, I had installed a navbar to navigate around the app and it was working completely fine until recently. Now the navbar is not showing up on the application even though it still works perfectly when I try anything locally. I have tried rake assets:precompile, bundle install, and all the usual suspects. I don't know what to do exactly. I have attached screenshots of my app in testing and production. This is the image of the two apps. This error first turned up when I created an account on the production application on Heroku. The logs show this error
ActionController::RoutingError (No route matches [GET] "/assets/~bootstrap/scss/bootstrap")
So if a public/assets/manifest.yml(Rails 4 uses a file called public/assets/manifest-.json instead) is detected in your app, Heroku assumed you are handling asset compilation yourself and will not attempt to compile your assets. On both versions you can generate this file by running $ rake assets:precompile locally and checking the resultant files into Git.
This means that I ran rake assets:precompile locally, even just once, and then checked in that manifest file that would then need to run assets:precompile and check the results into git before every deploy. It's quite a subtle change that can catch people out.
Removing the public/assets/manifest.yml file from my git repo and re-deploying the app, so that asset compilation is done automatically by Heroku again solved the error.

Error: Sprockets::FileNotFound: couldn't find file 'application.scss' for Heroku

I'm having some issues with Sprockets not finding a file during rake assets:precompile. I haven't had this issue before, but when I added a generated migration (which built locally), Heroku failed to build my app, and I don't know why, because it builds locally (without me running an additional rake assets:precompile).
Error message is this:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Sprockets::FileNotFound: could not find file: /tmp/build_dd4a799769e6963b7b292df72db58fd8/username-appname-uniqueid/app/assets/stylesheets/application.scss
Any help with why this is? Thank you for your time!
PS. As a side note - when I run "rake assets:precompile" and then push to Heroku, the app builds. However, an item with the css class "fa-bars" gets messed up... why is this?
Thanks!
I add the same issue with Sprockets 3.3.3 and our Rails 4.2.3 app.
I fixed it by cleaning our dyno build cache with:
heroku repo:purge_cache
Please note that your next deployment will take longer as bundler cache will be cleared too.
In rails 5 if you use Bower, uncomment in bower_rails.rb
#bower_rails.install_before_precompile = true

Do you always have to run rake assets:precompile locally?

I read the docs but can't seem to understand if you have to run rake assets:precompile locally each time you change scss file or any other assets? Isn't there an automatic way to do it? One of the things I have noticed is that I forget to run it sometimes and my heroku changes do not appear. There must be a way to set it up automatically in rails?
If I change
config.assets.compile = false
to true, will do that it? Is a disadvantage of doing that?
You don't have to precompile your assets for Heroku to serve them. Heroku will precompile your assets automatically if you have not already precompiled assets locally. Read this heroku doc regarding the asset pipeline in Rails 3 (even if you are already using Rails 4). Then read this doc regarding the asset pipeline in Rails 4 on heroku.
Pay particular attention to this part:
If a public/assets/manifest.yml is detected in your app, Heroku will
assume you are handling asset compilation yourself and will not
attempt to compile your assets. Rails 4 uses a file called
public/assets/manifest-.json instead. On both versions you
can generate this file by running $ rake assets:precompile locally and
checking the resultant files into Git.
rake assets:precompile must be run for production environment. Do not need to run the command for the development environment. The command is used to collect all files into one and so be lighter to serve in production. Under development the styles they are wanted in the assets folder. After running the command, the styles are placed in the public folder.
If you forget to run rake assets:precompile Heroku should do it automatically. One reason it may not be is if you have checked your public folder into git as then during slug compilation Heroku will assume you precompiled your assets and will not do it for you.
Setting config.assets.compile = true can slow down your application by a lot, which is why it is only used in development.

Heroku can't find files in my Ruby on Rails app - even though they are right there?

When I try to access my site, then check my Heroku logs, I see this error:
ActionView::Template::Error (couldn't find file 'reset'
2012-06-13T02:31:43+00:00 app[web.1]: (in
/app/app/assets/stylesheets/application.css:4)):
(application.css contains the line *= require reset)
Then I thought to run "heroku run bundle exec rake assets:precompile:all" but this gives a similar error:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
couldn't find file 'main/first.js.coffee'
(in /tmp/build_3428u21sggsoc/app/assets/javascripts/application.js:1)
Tasks: TOP => assets:precompile:primary
(That file is the first one required from my application.js, which has first line "//= require main/first.js.coffee")
In summary: my application runs fine locally, but when I deploy to Heroku, the files can no longer be found. Any ideas why?
Edit: here is the project tree. (There is one more directory before the app one, and that is the main project directory that also contains config, db, log, etc)
Another edit: there is no problem with .gitignore, or .slugignore.
At first, I would suggest you to run your application in production mode on your local computer. There are some errors (in assets but I also found some in routing) which can have impact only for production environment so you can test and fix them locally instead of having to do it from the production server.
About the asset precompilation on Heroku, the solution given by akjoe should result in compiled assets tracked in git repo : with this option, you should disable the asset precompilation which happen on Heroku and let Rails serve you assets (set config.serve_static_assets = true in your production.rb file) but this is not the best way to deal with the asset pipeline as you lost one of his major benefice which is freeing your rails application of request for asset.
To make it working properly, you should setup something like heroku explain : Using Rack::Cache with Memcached for Static Asset Caching in Rails 3.1+
I would also suggest you to try the assets precompilation locally in production environment RAILS_ENV=production bundle exec rake assets:precompile. To see if you got any error.
Finally you may want to check this different links to find useful information :
Rails 3.1+ Asset Pipeline on Heroku Cedar
Railscasts : #279 Understanding the Asset Pipeline
Rails Guide
I've had almost exactly the same problem and similar errors with stylesheets edits not taking effect... I found that I would edit css (or as in your case references to css files) which seemed to be ignored by Heroku. Turns out Heroku was ONLY referencing the stylesheets in the public/assets directory. I cleared this directory and was able to get it working.
I later found that you need to precompile your assets directory BEFORE you checkin to git. You would do this as follows:
Precompile assets directory: rake assets:precompile
Add the project files to the current Git repository: git add .
Checkin the file changes to the current Git repository: git commit
-am "description goes here"
Push the files to Heroku: git push heroku master (substitute
'master' for the branch you wish to push to Heroku).
Hope that helps!

Resources