Avatar upload issue (Ubuntu)

This was split from the win 11 wsl dev environment setup thread.

My issues relate to a dev setup (non-docker) installed on ubuntu 22.04.3

…Thanks for this, I had to do some extra manual steps though as the edited installer didn’t seem to install npm or ruby latest versions

Also using ubuntu-22.04

Install latest npm using (option 2): https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04

Install pnmp: npm install -g pnpm

Install latest ruby (method 3): https://ubuntuhandbook.org/index.php/2024/01/install-ruby-ubuntu-24-04/

Add this to bash.rc:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Install imagemagik manually, the latest version (make sure you go to the " Install latest version of ImageMagick from the source code (for advanced and desperate users)" section: https://itsfoss.com/install-imagemagick-ubuntu

Only after all of this was I able to log on to the instance….

So after spending the entire day getting the dev instance up and running, I was pretty pleased…everything seems to be ok, except uploading avatars. Specifically, as a user I can upload an avatar and in the avatar upload box it shows correctly, but when I click save it just displays the placeholder avatar…..no errors in log…

this is quite important to me as I set up the dev instance to test a migration and one of those tests is that it gets avatars :smiley: …so I want to make sure they work before going ahead with a test import.

Uploaded images in topics appear correctly, no issue

Anyone have any ideas? Any help much appreciated

URLs for pictures can be a bit tricky on local.

Make sure you are starting your local server with FORCE_HOSTNAME=localhost:4200 bin/ember-cli -u

It’s better to use a test instance in the cloud to mimic your final destination … in fact, I would recommend you test migrations in the cloud ultimately.

לייק 1

Tried that, no luck.

I’m so tired after spending the entire day getting this local dev environment to where it is, I can’t bring myself to think it was all pointless now :stuck_out_tongue: thought I was there!

My thought process for a local dev environment was:

run the import script locally, backup discord, put it on the proper cloud production instance when all looks good…

you can check the urls of the avatars in the browser dev tools and may find they are not correct

local installs are very useful for development and testing … just not perfect for manipulating images

לייק 1

What is probably happening is that WSL is not exposing 127.0.0.1 to Windows, so a Windows browser is not picking it up.

Instead try to launch from Chrome within WSL2 and use that?

My guess is the avatars are being displayed with a 127.0.0.1 address …

Ahh sorry I’m using Ubuntu, on a Ubuntu VM. Didn’t mean to hijack this win 11 thread

לייק 1

Here is the exact behaviour.

Image uploads in posts work fine.

Changing your user avatar seems to work when you first upload the picture and are still in the choose picture dialog:

but when you ‘Save changes’ the uploaded picture doesn’t display and shows the default one:

The picture did upload and can be viewed by going to the source:

and if you change the url in dev tools, it does display fine on the preferences page:

So…the difference is the url - the uploaded custom avatar has a “http://127.0.0.1:4200/uploads/default/original…..” but the page wants to display

“/user_avatar/127.0.0.1/user1/…….”

….what am I missing here?

note: in topics/posts the image displays correctly with the url: http://localhost:4200/uploads/default/original/……….etc

Any assistance appreciated!

Ok think I’m getting to the bottom of it, two problems, will report back when it’s working

Ok…

First problem - avatar path was ip address 127.0.0.1 whereas all the other urls were localhost - would that make a difference? I changed it anyway, by going into rails c (as it didn’t seem to pick the parameters up from the command line to start discourse (FORCE_HOST=localhost etc), they were blank in rails.

rails c
SiteSetting.force_hostname = "localhost"
SiteSetting.port = 4200
exit

then avatar paths were localhost and not ip address after I restarted the site. Avatars still weren’t working though.

further investigation of logs as soon as I did an avatar import:

tail -n 200 log/development.log

revealed:

convert: no decode delegate for this image format jpeg:/home/bob/discourse/public/uploads/default/original/1X/92bb0d46e6a4b8a1333505b9d2da59a5ed1721ec.jpeg[0]' @ error/constitute.c/ReadImage/752.\nconvert: no images defined jpeg:/tmp/discourse-thumbnail20260202-4096-qjyo93.jpeg' @ error/deprecate.c/ConvertImageCommand/3368.\n">

and after some digging I found out that it was because I had installed imagemagick but not the jpeg delegates FIRST. uninstalled Imagemagick, installed jpeg delegates (and others):

sudo apt install -y libpng-dev libtiff-dev libwebp-dev libheif-dev liblcms2-dev zlib1g-dev libjpeg-turbo8 libjpeg-turbo8-dev

and then reinstalled Imagemagick from source:

./configure \
  --prefix=/usr/local \
  --with-modules \
  --disable-static \
  --with-quantum-depth=16 \
  --with-jpeg=yes \
  --with-png=yes \
  --with-tiff=yes \
  --with-webp=yes \
  --with-heic=yes \
  --with-lcms=yes

make -j"$(nproc)"
sudo make install
sudo ldconfig

restarted the discourse server and avatars instantly worked :slight_smile:

I’m annoyed at myself for getting fixated on the ip/locahost url references instead of checking the basics….but there we go, I learned quite a bit in the last couple of days and it’s working now :slight_smile: