0x-api icon indicating copy to clipboard operation
0x-api copied to clipboard

Role 'api' does not exist.

Open rhrahul opened this issue 4 years ago • 5 comments

Hi, I cloned repo and followed all steps, but when I run yarn start command, I get this error,

{"level":"error","time":1585508440972,"pid":44459,"hostname":"Rahuls-MacBook-Pro.local","name":"error","length":95,"severity":"FATAL","code":"28000","file":"miscinit.c","line":"607","routine":"InitializeSessionUserId","msg":"role "api" does not exist","stack":"error: role "api" does not exist\n

my .env file is,

CHAIN_ID=1337
ETHEREUM_RPC_URL=http://ganache:8545

MESH_WEBSOCKET_URI=
MESH_HTTP_URI=
FEE_RECIPIENT_ADDRESS=
MAKER_FEE_ASSET_DATA=
MAKER_FEE_UNIT_AMOUNT=
MAKER_FEE_ASSET_DATA=
TAKER_FEE_UNIT_AMOUNT=
POSTGRES_URI=
WHITELIST_ALL_TOKENS=

Please guide me on what I am missing here. Thanks

rhrahul avatar Mar 29 '20 19:03 rhrahul

I also ran into this issue. It sounds like my situation may have been a little bit different than yours in that I had previously been able to run the 0x-API, but this emerged when I pulled the current master branch.

I was able to fix the issue locally by removing the postgres directory, which was created in the 0x-api root directory. Let me know if this fixes the issue for you as well.

jalextowle avatar Apr 08 '20 22:04 jalextowle

Hey @jalextowle , I tried as you said, but it doesn't seems to be working for me.

rhrahul avatar Apr 09 '20 17:04 rhrahul

@rhrahul , the current config in docker-compose.yml expects an existing postgres role api, however this doesn't come in the default postgres:9.6 image.

We'll look into fixing this by updating the docker-compose.yml file.

In the meantime, you can get around this by manually creating a role and database.

Start up docker services:

$ docker-compose up

Obtain container ID for the postgres container and start a shell into it:

$ docker ps
$ docker exec -it <CONTAINER_ID> /bin/bash

Start the psql utility:

psql

The rest of these commands should be run from within psql:

CREATE ROLE api WITH LOGIN ENCRYPTED PASSWORD 'api';
\du                        // verify that the new role is created
CREATE DATABASE api WITH OWNER = api;

After this try running yarn start again.

xianny avatar Apr 10 '20 16:04 xianny

Hey @xianny, I tried as you said but now I am getting following error,

column cnst.consrc does not exist QueryFailedError: column cnst.consrc does not exist

rhrahul avatar Apr 10 '20 18:04 rhrahul

FWIW my local version of postgres was conflicting with 0x API's exposed docker version of postgres.

A quick hackaround for me was:

  1. Changing the docker-compose.yml to expose postgres on a different port:
         volumes:
             - ./postgres:/var/lib/postgresql/data
         ports:
-            - "5432:5432"
+            - '3333:5432'
  1. Running my desired 0x API command (yarn test) with a custom POSTGRES_URI ENV var:
POSTGRES_URI=postgresql://api:api@localhost:3333/api yarn test

steveklebanoff avatar Apr 10 '20 22:04 steveklebanoff