ozee / vm-workspace

0 stars 0 forks source link

Failed tasks when running the application #1

Open kalisjoshua opened 1 year ago

kalisjoshua commented 1 year ago
vm-workspace (branch main) 
$ npm start

> @vm-workspace/source@0.0.0 start
> npx concurrently "npx nx serve vm-api" "npx nx serve vm-app"

[1] 
[1] > nx run vm-app:serve:development
[1] 
[0] 
[0]  >  NX   Running target serve for project vm-api and 1 task it depends on:
[0] 
[0]  
[0] 
[0] > nx run vm-api:docker-compose
[0] 
[1] Loading proxy configuration from: /Users/kalisjoshua/Documents/candidates/vm-workspace/apps/vm-app/proxy.conf.json
[0]  Container vm-api-pg-1  Starting
[0] Error response from daemon: Mounts denied: 
[0] The path /data/pg is not shared from the host and is not known to Docker.
[0] You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.
[0] See https://docs.docker.com/desktop/mac for more info.
[0] Warning: run-commands command "docker-compose -f apps/vm-api/docker-compose.yml up -d" exited with non-zero status code
[0] 
[0]  
[0] 
[0]  >  NX   Running target serve for project vm-api and 1 task it depends on failed
[0] 
[0]    Failed tasks:
[0]    
[0]    - vm-api:docker-compose
[0]    
[0]    Hint: run the command with --verbose for more details.
[0] 
[0]    View structured, searchable error logs at https://nx.app/runs/MawjlEdVh9
image
ozee commented 1 year ago

hi @kalisjoshua! It seems like docker on mac might require us to enable sharing for the specific path or volume. It gives a brief bit of instruction on this:

[0] The path /data/pg is not shared from the host and is not known to Docker.
[0] You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.

But it's not super clear and not something I needed to do using WSL2, I did find this, https://stackoverflow.com/questions/45122459/mounts-denied-the-paths-are-not-shared-from-os-x-and-are-not-known-to-docke that gives a bit of a better explanation to why they set it up this way.

Let me know if that doesn't get you past this error!

kalisjoshua commented 1 year ago

Thanks @ozee that moved me forward. Now getting an error "role postgres does not exist."

[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [NestFactory] Starting Nest application...
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] AppModule dependencies initialized +7ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] TypeOrmModule dependencies initialized +1ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] ClsModule dependencies initialized +0ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] HashModule dependencies initialized +9ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM     LOG [InstanceLoader] JwtModule dependencies initialized +2ms
[0] [Nest] 79881  - 06/15/2023, 8:04:55 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
[0] 
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
[0] 
[0] [Nest] 79881  - 06/15/2023, 8:04:58 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)...
[0] 
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
ozee commented 1 year ago

Hey @kalisjoshua can you show me the full readout for startup? I am curious if the docker-compose and setup postgres. I uploaded my .env file with the init commit so there shouldn't be any env variables missing.

ozee commented 1 year ago

Also, try docker-compose down --volumes and then run npm start again.

kalisjoshua commented 1 year ago
$ npm start

> @vm-workspace/source@0.0.0 start
> npx concurrently "npx nx serve vm-api" "npx nx serve vm-app"

[1] 
[1] > nx run vm-app:serve:development
[1] 
[0] 
[0]  >  NX   Running target serve for project vm-api and 1 task it depends on:
[0] 
[0]  
[0] 
[0] > nx run vm-api:docker-compose
[0] 
[1] Loading proxy configuration from: /Users/kalisjoshua/Documents/candidates/vm-workspace/apps/vm-app/proxy.conf.json
[0]  Container vm-api-pg-1  Running
[0] 
[0] > nx run vm-api:serve:development
[0] 
[1]   ➜  Local:   http://localhost:4200/
[0] Debugger listening on ws://localhost:9229/7bb61377-98c2-413b-8180-61f7a252415a
[0] Debugger listening on ws://localhost:9229/7bb61377-98c2-413b-8180-61f7a252415a
[0] For help, see: https://nodejs.org/en/docs/inspector
[0] 
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [NestFactory] Starting Nest application...
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] AppModule dependencies initialized +10ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] ClsModule dependencies initialized +0ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] HashModule dependencies initialized +11ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM     LOG [InstanceLoader] JwtModule dependencies initialized +2ms
[0] [Nest] 51103  - 06/16/2023, 11:18:54 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
[0] 
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
[0] 
[0] [Nest] 51103  - 06/16/2023, 11:18:57 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (2)...
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
[0] 
[0] [Nest] 51103  - 06/16/2023, 11:19:00 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (3)...
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
[0] 
[0] [Nest] 51103  - 06/16/2023, 11:19:03 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (4)...
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
[0] 
^C[0] npx nx serve vm-api exited with code 0
[1] npx nx serve vm-app exited with code 0
kalisjoshua commented 1 year ago
$ docker-compose down --volumes
no configuration file provided: not found
ozee commented 1 year ago
$ docker-compose down --volumes
no configuration file provided: not found

That makes sense actually since the configuration is in the vm-api app and not the root. There are two ways to handle that, we can pass a -f flag pointing to apps/vm-api/docker-compose.yml or cd into the apps/vm-api folder and run the docker-compose down --volumes again.

I did see another page that recommended manually deleting the db path and trying again after restarting docker (eg. /data/pg) but I'm unsure because I didn't really encounter these things while doing the development.

ozee commented 1 year ago

I wonder if it would be easier if I just wrote a docker file that can be run instead.

ozee commented 1 year ago

Hey @kalisjoshua, I pushed an update that moves the directory for docker to your ~ directory so that mac behaves. Can you pull that down and see if that works for you?

kalisjoshua commented 1 year ago

@ozee first of all, I appreciate your responsiveness through this. Second, I pulled your latest changes but still having the same issue.

~/Documents/candidates/vm-workspace (branch main) 
$ npm start

> @vm-workspace/source@0.0.0 start
> npx concurrently "npx nx serve vm-api" "npx nx serve vm-app"

[0] 
[0]  >  NX   Running target serve for project vm-api and 1 task it depends on:
[0] 
[0]  
[1] 
[1] > nx run vm-app:serve:development
[1] 
[0] 
[0] > nx run vm-api:docker-compose
[0] 
[1] Loading proxy configuration from: /Users/kalisjoshua/Documents/candidates/vm-workspace/apps/vm-app/proxy.conf.json
[0]  Container vm-api-pg-1  Running
[0] 
[0] > nx run vm-api:serve:development
[0] 
[1]   ➜  Local:   http://localhost:4200/
[0] Debugger listening on ws://localhost:9229/34fb4492-b560-487c-a89b-d1ed34002640
[0] Debugger listening on ws://localhost:9229/34fb4492-b560-487c-a89b-d1ed34002640
[0] For help, see: https://nodejs.org/en/docs/inspector
[0] 
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [NestFactory] Starting Nest application...
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] AppModule dependencies initialized +8ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] TypeOrmModule dependencies initialized +0ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] ConfigHostModule dependencies initialized +0ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] ClsModule dependencies initialized +0ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] ConfigModule dependencies initialized +0ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] HashModule dependencies initialized +11ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM     LOG [InstanceLoader] JwtModule dependencies initialized +2ms
[0] [Nest] 68559  - 06/19/2023, 10:37:46 AM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
[0] 
[0] error: role "postgres" does not exist
[0]     at Parser.parseErrorMessage (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:369:69)
[0]     at Parser.handlePacket (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:188:21)
[0]     at Parser.parse (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/parser.ts:103:30)
[0]     at Socket.<anonymous> (/Users/kalisjoshua/Documents/candidates/vm-workspace/node_modules/pg-protocol/src/index.ts:7:48)
[0]     at Socket.emit (node:events:513:28)
[0]     at addChunk (node:internal/streams/readable:324:12)
[0]     at readableAddChunk (node:internal/streams/readable:297:9)
[0]     at Socket.Readable.push (node:internal/streams/readable:234:10)
[0]     at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
ozee commented 1 year ago

@kalisjoshua no no, thank you. It's embarrassing that it didn't just work. My last thought is that it's some kind of permissions, I had Paul download it and it worked from his mac whenever I moved the postgres location to the Users folder. Did it create the /Users/kalisjoshua/ozee-vm-app-data folder path?

kalisjoshua commented 1 year ago

That exists.

$ ls ~/ozee-vm-app-data/pg/
PG_VERSION            pg_multixact/         pg_tblspc/
base/                 pg_notify/            pg_twophase/
global/               pg_replslot/          pg_wal/
pg_commit_ts/         pg_serial/            pg_xact/
pg_dynshmem/          pg_snapshots/         postgresql.auto.conf
pg_hba.conf           pg_stat/              postgresql.conf
pg_ident.conf         pg_stat_tmp/          postmaster.opts
pg_logical/           pg_subtrans/          postmaster.pid
ozee commented 1 year ago

That's bueno, maybe we can just do something like chmod -R 664 ~/ozee-vm-app-data to give it better recursive rights?

kalisjoshua commented 1 year ago

No change. Sorry.

ozee commented 1 year ago

Ok, let's remove that directory and have it try to run again. rm -rf ~/ozee-vm-app-data and then npm start. I wonder if maybe it generated that db data funky.

kalisjoshua commented 1 year ago

I was thinking about that too.

ozee commented 1 year ago

Let's hope that solves it then! haha

kalisjoshua commented 1 year ago

Nope. It is still the same thing. I killed the container, then removed the containers and images and restarted Docker Desktop. There were no volumes. And, I rm -rf-ed the ~/ozee-vm-app-data folder before trying again. Then got the same result.

ozee commented 1 year ago

That is disappointing, whenever you open your Docker Mac app, and go to File Sharing, (Docker -> Preferences... -> Resources -> File Sharing), is /Users or something similar within that list?

kalisjoshua commented 1 year ago

It is.

ozee commented 1 year ago

Trying to determine what is different here, I keep seeing this line here docker-compose down --volumes and then starting again. Is that similar to the command you ran within Docker?

kalisjoshua commented 1 year ago

I didn't run a command. I went into the Docker Desktop UI and looked at "Containers", "Images", and "Volumes". When I run docker-compose down --volumes in the root of the project it just errors. When I run it in the API folder I get:

[+] Running 2/2
 ✔ Container vm-api-pg-1   Removed                                                                                                                                     0.2s 
 ✔ Network vm-api_default  Removed  

But when I run npm start in the root of the project I get the same errors again.

ozee commented 1 year ago

Oh, Okay. Yeah, running it from the API folder is correct, that is where it is being generated. I would expect it to re-create the db again on running npm start but it seems like it isn't able to reach it from the app for some reason. I'll see what else I am able to find. Was really hoping that moving the location of the data folder would take care of that.

kalisjoshua commented 1 year ago

Attempting to helpful and stress relieving, a containerized DB is explicitly out of scope for this exercise partly because of this type of complication. Persisting the data in memory is all that is expected to let the focus be on the building of an application that exhibits the primary skills we are looking for.

ozee commented 1 year ago

Hey @kalisjoshua, I see that now, my thought was that I normally have a simple time with docker and pg, and am able to stand it up quickly enough that it wouldn't be a hassle, and for my initial build it at the very least was. But seeing the complications it caused here has given me cause to not do that.

That being said I took some time over my lunch and refactored the api to exclude pg and use in-memory. so npm start should work after a fresh npm install.

kalisjoshua commented 1 year ago

I got it running locally. Awesome! Thanks for all of the back and forth. I'm sure we'll talk soon.

ozee commented 1 year ago

Should have just done that sooner. Oh well.