How do I fix my pgvector error "could not open extension control file?"

The PostgreSQL extension pgvector sometimes returns the following error when you run the command CREATE EXTENSION pgvector;:

ERROR: could not open extension control file "/usr/pgsql-16/share/extension/pgvector.control": No such file or directory

This is because, despite the project being named pgvector, the creation command requires that you use vector as the extension name, like so:

CREATE EXTENSION vector;

For more details, see the pgvector documentation.