I had the same issue and resolved it by switching the cloud function base image to google-22-full (Ubuntu 22 full).
As mentioned here, there are different stacks with different included package that can be selected when editing cloud functions.