bors-ng
bors-ng copied to clipboard
Dev setup instructions don't work (MacOS)
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!
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 ..
I have the same issue on Linux.