I'm not sure if you want to ascribe this as "fix your environment", but if PGDATABASE is set in the environment (to anything other than postgres), the database creation commands fail, as psql connects to a database that doesn't exist.
Error: Command error: stdout=; stderr=psql: error: connection to server at "localhost" (::1), port 58453 failed: FATAL: database "xxx" does not exist
One option might be to explicitly set the database to postgres when running database management commands.