TileDB-Inc / TileDB-R

R interface to TileDB: The Modern Database
https://tiledb-inc.github.io/TileDB-R
Other
103 stars 18 forks source link

Fix MacOS rpath for local-core corner case #760

Closed johnkerl closed 2 months ago

johnkerl commented 2 months ago

Before

On MacOS for TileDB-R -- noting that as an internal developer I always have a local copy of core checked out -- I've always noticed:

# build and install
rm -f *.tar.gz; R CMD build --no-build-vignettes --no-manual .
R CMD INSTALL --no-test-load --no-docs --no-html *tar.gz
$ R
> library(tiledb)
Error: package or namespace load failed for ‘tiledb’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/johnkerl/R/tiledb/libs/tiledb.so':
  dlopen(/Users/johnkerl/R/tiledb/libs/tiledb.so, 0x0006): Library not loaded: @rpath/libtiledb.dylib
  Referenced from: <9D75719F-D075-3D56-BDDF-7429ACB097EE> /Users/johnkerl/R/tiledb/libs/tiledb.so
  Reason: tried: '/Library/Frameworks/R.framework/Resources/lib/libtiledb.dylib' (no such file), '/Library/Java/JavaVirtualMachines/jdk-11.0.18+10/Contents/Home/lib/server/libtiledb.dylib' (no such file)

I've always had this workaround:

$ alias rpatch
alias rpatch='install_name_tool -add_rpath /usr/local/lib ~/R/tiledb/libs/tiledb.so'

after which I can do library(tiledb).

This is to say: the MacOS install is broken until/unless I manually fix the rpath.

After

# build and install
rm -f *.tar.gz; R CMD build --no-build-vignettes --no-manual .
R CMD INSTALL --no-test-load --no-docs --no-html *tar.gz
$ R
> library(tiledb)
TileDB R 0.30.1 with TileDB Embedded 2.26.2 on macOS 15.0.
See https://tiledb.com for more information about TileDB.

Note

We already did this for tiledbsoma here: https://github.com/single-cell-data/TileDB-SOMA/pull/1372

The current PR simply copy-pastes the same logic to TileDB-R.