Skip to content

Commit 1224b01

Browse files
committed
Improved documentation and error reporting to work around macos DYLD_LIBRARY_PATH requirements (#42)
1 parent 02dffff commit 1224b01

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ To connect to a remote cluster you need:
2828
- A copy of the client library with matching major and minor version numbers. You really only need the `libfdb_c` dynamic library file to connect ([available on the fdb downloads page](https://www.foundationdb.org/download/)). But its usually easier to just install the fdb client library for your platform. See [Notes on API versions](#notes-on-api-versions) below for more information.
2929
- A copy of the `fdb.cluster` file for your database cluster. If you have installed foundationdb on your local machine in the default location, a copy of this file will be discovered and used automatically.
3030

31+
#### Step 1b (macos only)
32+
33+
If you're on a mac, add `export DYLD_LIBRARY_PATH=/usr/local/lib` to your .zshrc or .bash_profile. This is [needed due to macos binary sandboxing](https://github.com/josephg/node-foundationdb/issues/42).
34+
3135
#### Step 2
3236

3337
```

lib/native.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {platform} from 'os'
12
import path = require('path')
23

34
import FDBError from './error'
@@ -119,6 +120,20 @@ try {
119120
} catch (e) {
120121
console.error('Could not load native module. Make sure the foundationdb client is installed and')
121122
console.error('(on windows) in your PATH. https://www.foundationdb.org/download/')
123+
124+
// This is way more involved than it needs to be, but error messages are important.
125+
if (platform() === 'darwin') {
126+
const ldLibraryPath = process.env['DYLD_LIBRARY_PATH'] || ''
127+
if (!ldLibraryPath.includes('/usr/local/lib')) {
128+
const configFile = process.env['SHELL'] === '/bin/zsh' ? '.zshrc' : '.bash_profile'
129+
130+
console.error()
131+
console.error('MacOS note: You also need to set DYLD_LIBRARY_PATH="/usr/local/lib" due to notarization. Run:\n')
132+
console.error(` echo \'export DYLD_LIBRARY_PATH="/usr/local/lib"\' >> ~/${configFile}`)
133+
console.error(` source ~/${configFile}`)
134+
console.error('\nThen retry. See https://github.com/josephg/node-foundationdb/issues/42 for details.\n\n')
135+
}
136+
}
122137
throw e
123138
}
124139

0 commit comments

Comments
 (0)