bors-ng icon indicating copy to clipboard operation
bors-ng copied to clipboard

Dev setup instructions don't work (MacOS)

Open wcauchois opened this issue 3 years ago • 2 comments

In the instructions here, it says that script/setup && script/server should be enough to setup a local dev environment - however that did not appear to be the case for me.

I think I ended up getting it working, I'm going to write down my experience here.

Towards the end of the scripts/setup script, I got this error message:

Generated bors app

15:45:13.549 [error] GenServer #PID<0.1135.0> terminating
** (DBConnection.ConnectionError) tcp connect (localhost:5432): connection refused - :econnrefused
    (db_connection 2.4.1) lib/db_connection/connection.ex:100: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for BorsNG.Database.Repo couldn't be dropped: killed

That looked to me like Postgres wasn't running, so I shelled into the borsng-dev container and I had to manually start Postgres with sudo service postgresql start.

I also had to run the following commands:

mix ecto.create
mix ecto.migrate
cd assets && npm install

Finally, I was able to start the server with mix phx.server.

I can try to make a contribution to improve this experience, but I need some guidance on what the right behavior is. Do we need to update the README somehow? Or is there some bug in the borsng-dev container such that Postgres isn't starting correctly? And are migrations supposed to be automatically run at some point in the setup script?

Thanks!

wcauchois avatar Feb 04 '22 16:02 wcauchois

My workaround was copying some lines from script/Dockerfile:

diff --git a/script/setup b/script/setup
index f16eacf..96bf9c7 100755
--- a/script/setup
+++ b/script/setup
@@ -10,5 +10,7 @@ if [ -z $BORS_WITHIN_DOCKER ]; then
   docker start borsng-dev
   exec docker exec -it borsng-dev "$0" "$@"
 fi
+sudo runuser -u postgres -- /usr/lib/postgresql/12/bin/postgres -D /etc/postgresql/12/main/ 2>&1 > /dev/null &
+sleep 1
 mix do clean, deps.get, ecto.drop, ecto.create, ecto.migrate, compile
 cd assets; npm install; cd ..

jfirebaugh avatar Feb 10 '22 23:02 jfirebaugh

I have the same issue on Linux.

matthiasbeyer avatar Jul 29 '22 07:07 matthiasbeyer