Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable or Nightly doesn't work on M1 macOS - dyld issue with homebrew #1785

Closed
abhishiv opened this issue Apr 3, 2021 · 14 comments
Closed
Labels

Comments

@abhishiv
Copy link

abhishiv commented Apr 3, 2021

Environment

  • Operating system: macOS big sur 11.2.3

Description of issue

Postgres is installed via homebrw

⋊> ~/w/g/gratico on master ⨯ brew info  postgres                        23:43:26
Warning: Treating postgres as a formula. For the cask, use homebrew/cask/postgres
postgresql: stable 13.2 (bottled), HEAD
Object-relational database system
https://www.postgresql.org/
/opt/homebrew/Cellar/postgresql/13.2_1 (3,218 files, 43.4MB) *
  Poured from bottle on 2021-04-02 at 02:13:17
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/postgresql.rb
License: PostgreSQL

Error I get is following

./bin/postgrest
dyld: Library not loaded: /usr/local/opt/postgresql/lib/libpq.5.dylib
  Referenced from: /Users/abhishiv/work/gratico/gratico/./bin/postgrest
  Reason: image not found
@abhishiv abhishiv changed the title Stable or Nightly doesn't work on latest macOS Stable or Nightly doesn't work on latest macOS - dyld issue with homebrew Apr 3, 2021
@steve-chavez
Copy link
Member

Try installing postgrest with homebrew as well:

brew install postgrest

Ref: https://postgrest.org/en/v7.0.0/install.html

@abhishiv
Copy link
Author

abhishiv commented Apr 4, 2021

Hey @steve-chavez

Error: postgrest: no bottle available!
You can try to install from source with:
  brew install --build-from-source postgrest

Yeah but unfortunately I think the issue is that I'm on a m1 mac. So postgres is at /opt/homebrew/Cellar/postgresql instead of /usr/local/opt/postgresql that postgrest is expecting?

Also tried building via source and that also failed due to similar issue I guess.

⋊> ~/w/g/gratico on master ⨯ brew install --build-from-source postgrest                           20:36:08
Error: ghc: no bottle available!
You can try to install from source with:
  brew install --build-from-source ghc
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.

@abhishiv abhishiv changed the title Stable or Nightly doesn't work on latest macOS - dyld issue with homebrew Stable or Nightly doesn't work on M1 macOS - dyld issue with homebrew Apr 4, 2021
@jonasstenberg
Copy link

I'm in the same boat. Would love to have a pre-built ARM binary for my Macbook Pro M1.

@quindariuss
Copy link

@quindariuss
Copy link

I made an article on how to do this!

well not how to do the pre built binary but to build it from source on macos with the m1 chip

@kevcodez
Copy link

kevcodez commented May 5, 2021

Just ran into the same issues, the docker image also does not work on my M1 mac.

@kevcodez
Copy link

kevcodez commented May 5, 2021

With the help of Steve I managed to make it work. Downloaded the nightly Linux aarch 64 build.

Used this Dockerfile to build a custom image

Dockerfile

FROM arm64v8/ubuntu:focal

RUN apt-get update -y
RUN apt install libpq-dev zlib1g-dev jq gcc libnuma-dev -y

COPY postgrest /usr/bin/postgrest

COPY postgrest.conf /etc/postgrest.conf

EXPOSE 3000

USER 1000

CMD ["postgrest", "/etc/postgrest.conf"]

postgres.conf

db-uri = "postgres://postgres:postgres@host.docker.internal:5432/postgres"
db-schema = "public"
db-anon-role = "postgres"
jwt-secret = "super-secret-jwt-token-with-at-least-32-characters-long"

@yusufpapurcu
Copy link

As a note. Use latest nightly aarch build. 2020 linux releases not working.

@soedirgo
Copy link
Contributor

Tested the 8.0.0_1 bottle. Works on my machine.

@saxomagic
Copy link

Hi - closed #1979 because it is a duplicate, but not because it has been resolved - just making sure there is no misunderstanding. Would very much appreciate an arm64 M1-compatible docker image built with Nix. Also, documentation is not clear on how to proceed with the Nix build using the Nix docker image for running the nix-shell for build and dev, so perhaps a bit more there on how to actually get the Nix-built docker image of PostgREST out into DockerHub? Apologies if that part is self study / common knowledge, but having build docker images with docker build and pushed to DockerHub before, this method with Nix is quite a bit different.
Btw, the documentation is really awesome in general, so my compliments to all the effort that has gone into that - learned a lot just by reading it - thanks much.

@steve-chavez
Copy link
Member

@saxomagic Have you tried doing brew install postgrest? Seems brew already provides an ARM binary.

https://formulae.brew.sh/formula/postgrest

@soedirgo
Copy link
Contributor

@steve-chavez I think that is referring to an arm64/v8 Docker image (which is tracked on #1117). arm64/v8 images should generally work fine on M1, so "M1-compatible" isn't really a thing.

@saxomagic
Copy link

Thanks @steve-chavez and @soedirgo - yeah, I was over explicit there to avoid any confusion - arm64 would work fine on M1. @steve-chavez thanks for the reference to the arm64 PostgREST build via brew, but the equivalent of a Nix-built docker image for arm64 is what I'm really after, not simply an arm64 executable for postgREST. This would be to bring parity between amd64 and arm64 development using the docker image. As you know, the current situation is that the amd64 postgREST docker image consumes so much RAM when run on M1 arm64 (probably because of whatever amd64 -> arm64 translation is taking place) that it is only possible to run one posgREST image at a time, and nearly nothing else.

@steve-chavez
Copy link
Member

steve-chavez commented Dec 3, 2021

There's now a PostgREST ARM Docker image for v9.0.0 and latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

8 participants