Skip to content

Could not install uuid-ossp extension (or uuid_ossp) #1045

@yeroc-sebrof

Description

@yeroc-sebrof

I found the following issue when attempting to install uuid_ossp:

$ psql -X "postgresql://$POSTGRES_SERVER_ADMIN_USERNAME:$POSTGRES_SERVER_ADMIN_PASSWORD@$POSTGRES_DATABASE_URL/$POSTGRES_DATABASE_NAME"  -1 -c "CREATE EXTENSION IF NOT EXISTS uuid_ossp;"
ERROR:  extension "uuid_ossp" is not available
DETAIL:  Could not open extension control file "/usr/share/postgresql/15/extension/uuid_ossp.control": No such file or directory.
HINT:  The extension must first be installed on the system where PostgreSQL is running.

And when I tried to install it as uuid-ossp I would get this issue:

$ psql -X "postgresql://$POSTGRES_SERVER_ADMIN_USERNAME:$POSTGRES_SERVER_ADMIN_PASSWORD@$POSTGRES_DATABASE_URL/$POSTGRES_DATABASE_NAME"  -1 -c "CREATE EXTENSION IF NOT EXISTS uuid-ossp;"
ERROR:  syntax error at or near "-"
LINE 1: CREATE EXTENSION IF NOT EXISTS uuid-ossp;

After some digging I went into a shell on the running container and ran the following moves:

    5  mv /usr/share/postgresql/15/extension/uuid-ossp.control /usr/share/postgresql/15/extension/uuid_ossp.control
    6  mv /usr/share/postgresql/15/extension/uuid-ossp--1.0--1.1.sql /usr/share/postgresql/15/extension/uuid_ossp--1.0--1.1.sql
    7  mv /usr/share/postgresql/15/extension/uuid-ossp--1.1.sql /usr/share/postgresql/15/extension/uuid_ossp--1.1.sql

After I done this:
$ psql -X "postgresql://$POSTGRES_SERVER_ADMIN_USERNAME:$POSTGRES_SERVER_ADMIN_PASSWORD@$POSTGRES_DATABASE_URL/$POSTGRES_DATABASE_NAME" -1 -c "CREATE EXTENSION IF NOT EXISTS uuid_ossp;" worked.

No idea how I would implement a proper fix for this so I'm submitting as a Issue instead. Please let me know if there's anything else I can help with.

For anyone else suffering this issue here's the janky dockerfile I use to temporarily fix this:

FROM postgres

RUN mv /usr/share/postgresql/15/extension/uuid-ossp.control /usr/share/postgresql/15/extension/uuid_ossp.control && \
    mv /usr/share/postgresql/15/extension/uuid-ossp--1.0--1.1.sql /usr/share/postgresql/15/extension/uuid_ossp--1.0--1.1.sql && \
    mv /usr/share/postgresql/15/extension/uuid-ossp--1.1.sql /usr/share/postgresql/15/extension/uuid_ossp--1.1.sql


EXPOSE 5432
CMD ["postgres"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions