Running Anvil on an M1 Mac

What I’m trying to do:

I’m trying to run an Anvil server locally on my M1 MacBook Pro and have run into an error.

What I’ve tried and what’s not working:

I’ve tried following the guide here and got the below error.

Error:

Found Anvil App Server JAR in package directory
[INFO  anvil.app-server.postgres] Launching embedded Postgres database. Find Postgres daemon logs in the ' .anvil-data ' directory.
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Process [.anvil-data/db-bin/PG-a2a9bc65661eac6f108fc920268a87b3/bin/initdb, -A, trust, -U, postgres, -D, .anvil-data/db, -E, UTF-8] failed
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at clojure.core$deref_future.invokeStatic(core.clj:2317)
	at clojure.core$future_call$reify__8544.deref(core.clj:7042)
	at clojure.core$deref.invokeStatic(core.clj:2337)
	at clojure.core$deref.invoke(core.clj:2323)
	at anvil.app_server.postgres$start_postgres_with_timeout.invokeStatic(postgres.clj:47)
	at anvil.app_server.postgres$start_postgres_with_timeout.invoke(postgres.clj:37)
	at anvil.app_server.postgres$launch_bundled_db_BANG_.invokeStatic(postgres.clj:146)
	at anvil.app_server.postgres$launch_bundled_db_BANG_.invoke(postgres.clj:87)
	at anvil.app_server.run$with_bundled_postgres_if_configured.invokeStatic(run.clj:319)
	at anvil.app_server.run$with_bundled_postgres_if_configured.invoke(run.clj:312)
	at anvil.app_server.run$with_bundled_postgres_if_configured.invokeStatic(run.clj:313)
	at anvil.app_server.run$with_bundled_postgres_if_configured.invoke(run.clj:312)
	at anvil.app_server.run$_main.invokeStatic(run.clj:418)
	at anvil.app_server.run$_main.doInvoke(run.clj:414)
	at clojure.lang.RestFn.applyTo(RestFn.java:137)
	at anvil.app_server.run.main(Unknown Source)
Caused by: java.lang.IllegalStateException: Process [.anvil-data/db-bin/PG-a2a9bc65661eac6f108fc920268a87b3/bin/initdb, -A, trust, -U, postgres, -D, .anvil-data/db, -E, UTF-8] failed
	at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.system(EmbeddedPostgres.java:632)
	at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.initdb(EmbeddedPostgres.java:252)
	at io.zonky.test.db.postgres.embedded.EmbeddedPostgres.<init>(EmbeddedPostgres.java:159)
	at io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder.start(EmbeddedPostgres.java:583)
	at anvil.app_server.postgres$start_postgres_with_timeout$fn__527.invoke(postgres.clj:39)
	at clojure.core$binding_conveyor_fn$fn__5823.invoke(core.clj:2047)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)
Failed to start built-in Postgres database: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: Process [.anvil-data/db-bin/PG-a2a9bc65661eac6f108fc920268a87b3/bin/initdb, -A, trust, -U, postgres, -D, .anvil-data/db, -E, UTF-8] failed
More logs are available in .anvil-data/postgres.log.
Some common causes of this problem:
 - Are you launching this server as 'root' on a UNIX system?
   Postgres will not run as root; try launching the server as an ordinary user.
 - Are you running this server on an unusual architecture or OS? (Mac OS X/aarch64)

Any help would be appreciated!

This could be an issue with aarch64. On M series machines you can set up a separate Rosetta terminal which will run things as if it were using an Intel chip. You could try that as it only takes a few minutes to set that up.

However if it were me I would probably go straight for Docker if I wanted to run this locally.

2 Likes

Thank you for your reply. The error message above was from a Rosetta terminal. I’ll look into Docker, though.

Thank you!