Skip to content

Commit

Permalink
Improved documentation and error reporting to work around macos DYLD_…
Browse files Browse the repository at this point in the history
…LIBRARY_PATH requirements (#42)
  • Loading branch information
josephg committed Jun 10, 2020
1 parent 02dffff commit 1224b01
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ To connect to a remote cluster you need:
- 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.
- 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.

#### Step 1b (macos only)

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).

#### Step 2

```
Expand Down
15 changes: 15 additions & 0 deletions lib/native.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {platform} from 'os'
import path = require('path')

import FDBError from './error'
Expand Down Expand Up @@ -119,6 +120,20 @@ try {
} catch (e) {
console.error('Could not load native module. Make sure the foundationdb client is installed and')
console.error('(on windows) in your PATH. https://www.foundationdb.org/download/')

// This is way more involved than it needs to be, but error messages are important.
if (platform() === 'darwin') {
const ldLibraryPath = process.env['DYLD_LIBRARY_PATH'] || ''
if (!ldLibraryPath.includes('/usr/local/lib')) {
const configFile = process.env['SHELL'] === '/bin/zsh' ? '.zshrc' : '.bash_profile'

console.error()
console.error('MacOS note: You also need to set DYLD_LIBRARY_PATH="/usr/local/lib" due to notarization. Run:\n')
console.error(` echo \'export DYLD_LIBRARY_PATH="/usr/local/lib"\' >> ~/${configFile}`)
console.error(` source ~/${configFile}`)
console.error('\nThen retry. See https://github.com/josephg/node-foundationdb/issues/42 for details.\n\n')
}
}
throw e
}

Expand Down

0 comments on commit 1224b01

Please sign in to comment.