This error happened to me using Docker, but production on Heroku was fine.
Here is my Dockerfile
FROM ruby:3.2.0
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash -
RUN apt update -q && apt install -y \
build-essential \
libpq-dev \
postgresql-client \
nodejs \
nano \
libvips > /dev/null