thewca / wca-live

Platform for running WCA competitions and sharing live results with the world
https://live.worldcubeassociation.org
70 stars 23 forks source link

Unable to run the repository locally #214

Closed julesDesjardin closed 7 months ago

julesDesjardin commented 7 months ago

Hi,

To develop a tool using WCA Live I would like to have a local copy so I can run tests on it. I have tried both the local and the Docker method, but both fail.

In local, when running mix dev.setup, it looks like it compiles the code properly then gives a ** (Mix) The task "dev.setup" could not be found error. Running mix phx.server gives an authentication error for the PostgreSQL database, and then fails because it can't connect to the DB.

With docker, the output is quite longer. Here are the interesting parts I have tried to isolate:

app-1       | [debug] QUERY OK source="terms" db=2.1ms queue=1.0ms idle=5.6ms
app-1       | SELECT t0."key", t0."value" FROM "terms" AS t0 WHERE (t0."key" = $1) ["records_store"]
app-1       | npm ERR! code ENOTEMPTY
app-1       | npm ERR! syscall rename
app-1       | npm ERR! path /app/client/node_modules/ajv
app-1       | npm ERR! dest /app/client/node_modules/.ajv-YFOBB5co
app-1       | npm ERR! errno -39
app-1       | npm ERR! ENOTEMPTY: directory not empty, rename '/app/client/node_modules/ajv' -> '/app/client/node_modules/.ajv-YFOBB5co'

And later

app-1 | sh: 1: vite: not found

Opening port 3000 doesn't work (the browser says the connection reset), and on port 4000 I get the following screenshot + the following output in the terminal:

Screenshot from 2024-03-16 08-18-53

app-1       | Server: localhost:4000 (http)
app-1       | Request: GET /
app-1       | ** (exit) an exception was raised:
app-1       |     ** (File.Error) could not read file stats "/app/_build/dev/lib/wca_live/priv/static/index.html": no such file or directory
app-1       |         (elixir 1.14.2) lib/file.ex:408: File.stat!/2
app-1       |         (plug_cowboy 2.6.1) lib/plug/cowboy/conn.ex:41: Plug.Cowboy.Conn.send_file/6
app-1       |         (plug 1.14.2) lib/plug/conn.ex:497: Plug.Conn.send_file/5
app-1       |         (wca_live 0.1.0) lib/wca_live_web/controllers/catch_all_controller.ex:1: WcaLiveWeb.CatchAllController.action/2
app-1       |         (wca_live 0.1.0) lib/wca_live_web/controllers/catch_all_controller.ex:1: WcaLiveWeb.CatchAllController.phoenix_controller_pipeline/2
app-1       |         (phoenix 1.7.7) lib/phoenix/router.ex:430: Phoenix.Router.__call__/5
app-1       |         (wca_live 0.1.0) lib/wca_live_web/endpoint.ex:1: WcaLiveWeb.Endpoint.plug_builder_call/2
app-1       |         (wca_live 0.1.0) lib/plug/debugger.ex:136: WcaLiveWeb.Endpoint."call (overridable 3)"/2
app-1       |         (wca_live 0.1.0) lib/wca_live_web/endpoint.ex:1: WcaLiveWeb.Endpoint.call/2
app-1       |         (phoenix 1.7.7) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
app-1       |         (plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2
app-1       |         (cowboy 2.10.0) /app/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
app-1       |         (cowboy 2.10.0) /app/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
app-1       |         (cowboy 2.10.0) /app/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
app-1       |         (stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

I'm using Ubuntu 22.04.2 LTS. I'm not familiar with Elixir so please tell me if you need more info from my side.

Thanks! Jules

jonatanklosko commented 7 months ago

It should've been mix setup, I corrected the readme. This also creates the database, so that's why it had issues connecting.

I double-checked that Docker works for me locally. I think the issue may be that you tried to setup without Docker, which created some download/compile artefacts. The Docker setup also mounts the whole directory into the container, so sometimes there can be weird permission issues or similar if the files are already there.

You can remove the build files rm -rf _build deps client/node_modules and try either of the approaches again. If there are still issues, let me know :)

julesDesjardin commented 7 months ago

Nevermind, I pulled a clean repo again and the Docker worked :)

I guess my initial mistake was to run it in sudo, it must have damaged the repo somehow, but after adding permissions to Docker so I could run it without sudo, it seems to work perfectly!