Rails Asset - NoMethodError `dependency_digest` - ruby-on-rails

Seemingly out of nowhere a rails project has broken for me on my local machine. The same codebase is working on production though, interestingly enough.
As soon as any asset tries to load I get the following error:
undefined method `dependency_digest' for #<Sprockets::StaticAsset:0x007fefb93d0d28>
The error appears even as the site tries to load the stylesheet_link_tag, but it seems to be happening for all assets.
Inasmuch as I can tell, I've made no changes to incite this error. In fact, the local server was working (both with pow and webrick) and then, just stopped. After no changes.
I've tried reverting the history back through my commits, but with absolutely no luck.
Any ideas?

This should solve it.
rake tmp:cache:clear

On Heroku, I ran into this problem after switching around some buildpacks. The accepted answer on this SO post did NOT fix my problem (rake tmp:cache:clear) although it may have fixed other people's problems, the only way I could fix this was using:
heroku repo:purge_cache -a appname
see https://github.com/heroku/heroku-repo for documentation on the heroku repo plug-in

Related

Trying to deploy Sinatra app to Heroku with psql database, getting load error

I'm not the most experienced of developers so please excuse me if this is a stupid question.
I am trying to deploy a Sinatra app that uses PostgreSQL as it's database. My application works locally but then when I try to deploy to Heroku, I get this error:
Screenshot of Terminal after I try to push to heroku master
I have no idea what is going on. I don't think I'm requiring anything incorrectly b/c I would think that it wouldn't work locally if that were the case. I tried running the bit of code that says "bundle exec rake -P" but it didn't do anything as far as I know. I thought maybe I'd have to create a database and migrate it since I did that with a Rails app I was working on, but this is in Sinatra, so not sure if you have to do something entirely different.
It apparently deployed to Heroku, but when I run heroku open, it doesn't work. I just get a page that says to try again later and look at the log.
Any ideas on how to solve this issue?

Heroku Cedar-14 and libjpeg.so.62

After upgrading a production application on Heroku to cedar-14, I am running into issues with carrierwave-video-thumbnailer. In particular, I get the error:
ffmpegthumbnailer: error while loading shared libraries: libjpeg.so.62: cannot open shared object file: No such file or directory
After looking into this, I found that other people are having issues with libjpeg after upgrading to cedar-14 (for other gems besides ffmpegthumbnailer)
My questions are:
Is there a way to fix this?, or otherwise
How can I revert back to cedar-10?
(I tried heroku stack:set cedar-10 but get the error resource not found)
You only have a limited time left on cedar-10, so you'd do well to try to fix the issue. However, if you need to revert it temporarily, read on.
heroku stack:set cedar doesn't seem to be working anymore, probably because it is a ticking time bomb.
To rollback, you can use the heroku rollback functionality.
First, get the version number of the most recent release before you upgraded.
heroku releases
Then, do:
heroku rollback v65
(using the version you identified from the previous step instead of v65)
Good luck!

Heroku not reflecting changes made to Redmine code

I'm having an odd and somewhat confusing problem.
I am trying to install Redmine on Heroku. I followed the instructions and well lets say it hasn't been a smooth ride.
I am now trying to do the db:migrate process. (I had to edit all the cruft in the application.rb to get this far, and don't know yet where this will lead.)
In doing the migration however, I get the message
Plugins in vendor/plugins (/app/vendor/plugins) are no longer allowed. Please, put your Redmine plugins in the `plugins` directory at the root of your Redmine directory (/app/plugins)
Through StackOverflow and some other sites, I have found where this message is generated (environment.rb) and have removed the code that generates it.
However, when I push to Heroku and try the migrate again, the same message reoccurs.
I have tried cloning the Heroku repo/app down to a test directory and when I check the environment.rb file, the code is not there, however if I try the migrate (or any rake task for that matter) the message still occurs. Even from the test directory.
I've looked for the same message in other parts of the code, but haven't found it yet. Have I missed something?
There's one of two things at play here
You're not fixing the problem in your code - running it locally in production mode will show this
OR
You're not pushing your code to Heroku correctly. Are you developing on the master branch? Are you developing in a feature branch? If so, are you pushing that branch into master on Heroku? (git push heroku feature_branch:master)
Okay I figured out what was happening. It's amazing what a good nights sleep can accomplish!
It turns out the cruft in the application.rb file that I mentioned earlier was basically the other files in the config directory appended to app.rb. These included the yml files along with other files like environment.rb and routes.rb. And in amongst this crap was the plugin panic code I had deleted from environment.rb
(It finally came to light when running rake after some changes told me that the application was already initialised!)
So I deleted all this appended nonsense from application.rb and viola! working.
I have no idea why this was done this way as redmine works fine (so far) without it.

Why is there an ActionView::Template::Error when the image is there and precompiled?

I deployed a change to a Ruby on Rails app on heroku (cedar) that included a new image.
UPDATE: I can reproduce the problem locally if I switch to production mode. The rest of what I said is accurate.
When I navigate to the page with an image_tag for that image, I receive the following error:
ActionView::Template::Error (image_name.png isn't precompiled)
Here's what I've done to diagnose/solve the issue so far:
I ran heroku run rake assets:precompile RAILS_ENV=production to ensure that the assets were precompiling without error. Everything looks fine.
I also compiled assets locally and deployed with everything precompiled (which heroku noticed during deploy), but received the same error.
Other images are fine.
When I navigate to http://appname.com/assets/dir/image_name.png I can see the image fine.
What could it be? I'm interested in solving the problem, and in work arounds for now.
In config/environments/production/rb:
config.assets.compile = true
This shouldn't be necessary, but creates a fallback plan Rails thinks that an asset doesn't exist that does. It's unclear why the problem happened in the first place.

Heroku ignoring recent migrations

I just ran heroku rake db:migrate and three of my most recent migrations are being ignored completely. I've pushed everything to Heroku and github but it's like Heroku doesn't think these even exist.
git status reveals nothing amiss, and my Github repo contains the migration files in the right place.
What's wrong?
Running "heroku restart" from the command line sometimes fixes the issue too.
From what you've said it should work..
If you're completely stuck, you could always try pulling your production database from heroku, migrating on your local machine and then pushing the database back up to heroku?
At the very least you might be able to see what's going on in your database at least?
http://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku/

Resources