Cached avatars not showing up after migration

(Peter Curry) #1


I’ve been using Discourse for a few months (thank you!), originally using a Bitnami stack. Yesterday I bit the bullet and got the latest version running in Docker (on a Linode server, the same one the old Bitnami stack was running on). I followed the migration instructions from Advanced, manual method of manually creating and restoring Discourse backups, and almost all the content and data came through.

The one thing that isn’t working is the avatar thumbnails. Locally-uploaded avatars only show up at certain sizes, for example the 50px one doesn’t show up ( but that user’s profile page looks fine (Profile - Straan - Dinosaur Polo Club). I reuploaded my avatar and, after changing the filename to force it to regenerate the thumbnails, it works everywhere. So newly uploaded avatars are ok. Gravatars aren’t working at all.

I’ve double-checked and all the uploads came across from the previous install. The directory /srv/discourse/apps/discourse/htdocs/public/uploads/default in the old Bitnami install was moved to /var/www/discourse/public/uploads/default in the new Docker container. I’ve run rake avatars:clean and avatars:refresh to no avail.

Any advice on where to start looking?



(Sam Saffron) #2

You may notice this is not size related, for example x49 works just fine:

Whats happening is that you did not copy all the optimized images over. I think this fix should do the trick, but be sure to have a full backup just in case.

cd /var/discourse
./launcher ssh app
rails c
> OptimizedImage.destroy_all
> exit
rake posts:rebake

This will force a full rebake of everything and trigger new optimized images.

(Peter Curry) #3

Thanks Sam! That’s fixed it for local avatars. The existing gravatar images still aren’t working though—at any size they’re resulting in a white 1x1px image. Do you know what could be going wrong with them?

(Sam Saffron) #4

Sounds like you need to force it to download all the gravatars…

Does this fix it:


If not you probably have corrupt uploads. @zogstrip can we add a rake task that removes uploads from the upload table if they no longer exist on disk for local store?

(Peter Curry) #5

Ok, I think I’m doing something wrong (I’m not fluent in Ruby at all). What I’m doing is:

sudo ./launcher enter app
rails c
> UserAvatar.each(&:update_gravatar!)

I get the result:

NoMethodError: undefined method `each' for #<Class:0x007f702d962108>
from /var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.5/lib/active_record/dynamic_matchers.rb:26:in `method_missing'

I’m using ‘enter app’ instead of sshing in as ssh didn’t authenticate for me (similar to Docker password). I tried fixing the auth issue but couldn’t after a few hours so tried enter app instead.

Thanks so much for your help!

(Sam Saffron) #6

Sorry, was missing a .all there

(Peter Curry) #7

Ah right, that command worked and listed a whole bunch of UserAvatar objects. The avatars are still showing up as 1x1px images though unfortunately.

Where should be the missing uploads be? When I migrated, I copied all the files from the directory in the old Bitnami install:


into the new install at:


There are a whole bunch of numbered directories, as well as ‘avatars’ and ‘_optimized’. Should that have caught all the cached Gravatar images?

(Sam Saffron) #8

Really our rake task should fix all this mess if you have a local avatar store, hold tight maybe @zogstrip can whip something up. Essentially if our DB is saying a file is there and a file is not there, we should be smart enough to remove the upload.

(Peter Curry) #9

Cool, will do! Thanks.

(Régis Hanol) #10

I just pushed a new rake task :rabbit2:

You can launch it via bundle exec rake uploads:clean_up

(Peter Curry) #11

Thanks for all your help, and sorry for not replying sooner. Got caught up with other things and ended up shifting server again, this time to a standard docker setup on Digital Ocean instead of Linode. Everything’s running much smoother now.

The new rake task did fix the remaining non-Gravatar avatars and some of our embedded image links, but the Gravatars aren’t working still and we have a few dodgy uploaded images. New uploads are working ok.

For example, in this post:

The thumbnails can’t be found, but the full-size images are both there.

Other posts in that thread (most have images embedded in them) don’t have working thumbnails or full-size images. I think that all the embedded images worked ok before the rake task was run. I do have the SQL and upload backups still, but that may have been after I ran the script the first time on the old server.

I’m happy to provide server access (and pay!) if that would make it easier to fix.

(Baptiste Michaud) #12

I seems to have the same problem with my installation.

In fact, gravatar image are downloaded, but optimized images are not created,

Any idea ?

(Mohit Joshi) #13

Is these a way to cleanup for avatars present on S3. All avatars on our forum are broken and nothing seems to fix these.