timescale / timescaledb-toolkit

Extension for more hyperfunctions, fully compatible with TimescaleDB and PostgreSQL 📈
https://www.timescale.com
Other
353 stars 47 forks source link

Unable to install timescaledb toolkit on macos, following instructions on timescaledb website #354

Open tonyalaribe opened 2 years ago

tonyalaribe commented 2 years ago

Relevant system information:

Describe the bug cargo pgx install --release fails with error

error: failed to add native library ~/Projects/timescaledb-toolkit/target/release/build/pgx-pg-sys-bf45ab7e05d726b4/out/cshim/libpgx-cshim-14.a: file too small to be an archive

error: could not compile `pgx-pg-sys` due to previous error

To Reproduce Steps to reproduce the behavior:

  1. follow instructions on the timescale db website with latest rust version, on a mac

Expected behavior Should install timescaledb-toolkit successfully

Actual behavior Fails with error

Screenshots

image
tonyalaribe commented 2 years ago

I upgraded pgx to v0.2.6 but still get the error

image
JLockerman commented 2 years ago

That's an odd one; the C compiler building the shim is building an archive that LLVM can't understand. Is this an M1 mac? They occasionally run into odd issues when they get confused if they should be compiling x86 or ARM, see this for instance. What does file $(which cargo) say?

JLockerman commented 2 years ago

https://github.com/rust-lang/rust/issues/81790 suggests arch -arm64 may help

tonyalaribe commented 2 years ago

Hi @JLockerman I'm actually on x86 (not the m1).

❯ file $(which cargo)
/Users/tonyalaribe/.cargo/bin/cargo: Mach-O 64-bit executable x86_64

setting the arch to arm64 doesn't help

rtwalker commented 2 years ago

Hi @tonyalaribe, I'd like to help figure this one out if you're still looking to install the toolkit!

We've just upgraded the version of pgx we're using to 0.4.5 which has made life on macOS easier for me. Maybe you'll have the same luck if you cargo install --version '=0.4.5' cargo-pgx and re-try the installation steps?

tonyalaribe commented 2 years ago

I switch computers recently to an m1 mac, so I unfortunately can't test this anymore. I also resolved to using the docker image instead of installing the toolkit in my default postgres

ikasou commented 2 years ago

Hi @tonyalaribe, I'd like to help figure this one out if you're still looking to install the toolkit!

We've just upgraded the version of pgx we're using to 0.4.5 which has made life on macOS easier for me. Maybe you'll have the same luck if you cargo install --version '=0.4.5' cargo-pgx and re-try the installation steps?

Same here, on an M1 MacBook Air with cargo pix 04.5, Postgresql 14.3, timescaledb 2.6.1: Screenshot 2022-06-15 at 16 23 39

Happy to run any tests you think relevant ..

rtwalker commented 2 years ago

Same here, on an M1 MacBook Air with cargo pix 04.5, Postgresql 14.3, timescaledb 2.6.1

Happy to run any tests you think relevant ..

How did you install Postgres? i.e. what about file $(which pg_config)

Also, our README has the following command:

cargo install --version '=0.4.5' cargo-pgx && cargo pgx init --pg13 pg_config

but if you're using with Postgres 14 you probably want

cargo pgx init --pg14 pg_config

instead.

Another (possible) difference in my setup is that I have Rust installed via rustup instead of brew.

I'm hopeful we can figure this out!

ikasou commented 2 years ago

Hi, thanks for coming back. Retracing my steps, I see I was indeed careful:

cargo pgx init --pg14 /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config

(so the Postgres root dir is at /Applications/Postgres.app/Contents/Versions/14:

ikasou@MacBook-Air-M1 extension % /Applications/Postgres.app/Contents/Versions/latest/bin/pg_config BINDIR = /Applications/Postgres.app/Contents/Versions/14/bin DOCDIR = /Applications/Postgres.app/Contents/Versions/14/share/doc/postgresql HTMLDIR = /Applications/Postgres.app/Contents/Versions/14/share/doc/postgresql INCLUDEDIR = /Applications/Postgres.app/Contents/Versions/14/include PKGINCLUDEDIR = /Applications/Postgres.app/Contents/Versions/14/include/postgresql INCLUDEDIR-SERVER = /Applications/Postgres.app/Contents/Versions/14/include/postgresql/server LIBDIR = /Applications/Postgres.app/Contents/Versions/14/lib PKGLIBDIR = /Applications/Postgres.app/Contents/Versions/14/lib/postgresql LOCALEDIR = /Applications/Postgres.app/Contents/Versions/14/share/locale MANDIR = /Applications/Postgres.app/Contents/Versions/14/share/man SHAREDIR = /Applications/Postgres.app/Contents/Versions/14/share/postgresql SYSCONFDIR = /Applications/Postgres.app/Contents/Versions/14/etc/postgresql PGXS = /Applications/Postgres.app/Contents/Versions/14/lib/postgresql/pgxs/src/makefiles/pgxs.mk CONFIGURE = '--prefix=/Applications/Postgres.app/Contents/Versions/14' '--with-includes=/Applications/Postgres.app/Contents/Versions/14/include' '--with-libraries=/Applications/Postgres.app/Contents/Versions/14/lib' '--enable-thread-safety' '--with-openssl' '--with-bonjour' '--with-libxml' '--with-libxslt' '--with-python' '--with-readline' '--with-uuid=e2fs' '--with-icu' '--with-lz4' 'CFLAGS= -Os -mmacosx-version-min=10.12 -arch arm64 -arch x86_64' 'CXXFLAGS= -Os -mmacosx-version-min=10.12 -arch arm64 -arch x86_64' 'PKG_CONFIG_LIBDIR=/Applications/Postgres.app/Contents/Versions/14/lib/pkgconfig' 'ICU_CFLAGS=-I/Applications/Postgres.app/Contents/Versions/14/share/icu' 'ICU_LIBS=-licui18n -licuuc' 'PYTHON=/Library/Frameworks/Python.framework/Versions/3.9/bin/python3' CC = gcc CPPFLAGS = -I/Applications/Postgres.app/Contents/Versions/14/share/icu -I/Applications/Postgres.app/Contents/Versions/14/include/libxml2 -I/Applications/Postgres.app/Contents/Versions/14/include -I/Applications/Postgres.app/Contents/Versions/14/include CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Werror=unguarded-availability-new -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -Os -mmacosx-version-min=10.12 -arch arm64 -arch x86_64 CFLAGS_SL = LDFLAGS = -L/Applications/Postgres.app/Contents/Versions/14/lib -L/Applications/Postgres.app/Contents/Versions/14/lib -L/Applications/Postgres.app/Contents/Versions/14/lib -Wl,-dead_strip_dylibs LDFLAGS_EX = LDFLAGS_SL = LIBS = -lpgcommon -lpgport -llz4 -lxslt -lxml2 -lssl -lcrypto -lz -lreadline -lm VERSION = PostgreSQL 14.3 )

rtwalker commented 2 years ago

I am aware of https://github.com/tcdi/pgx/issues/566 which seems specific to Postgres.app installations, and I'm not sure if a workaround exists.

Until that issue is fixed, I'm using homebrew postgresql (and postgresql@13) without any problems. I'd recommend using those formulae if that option is available to you.