happybeing / happybeing/safe-cli-boilerplate
feature: package the SAFE API dlls in the executable
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
The build scripts documented in README.md (e.g. `npm run build-mock`) copy the SAFE Network dlls into a folder (`node_modules`) adjacent to the packaged executable which must be present with the executable or it will fail when it attempts to use the SAFE API. It would be better if the dlls were packaged inside the executable rather than having to be distributed separately.
The prototype script `npm run testbuild` does in fact package the SAFE API dlls inside the executable and so does not place them in a subdirectory next to the exectuable. Unfortunately this does not work, and results in an error when the executable attempts to access the SAFE API.
For example on both platforms tested (Linux and Windows) we get something like this:
```
$ dist/mock/safecmd
.git - 4 KB
.gitignore - 992 B
LICENSE - 34.32 KB
README.md - 3.51 KB
cli.js - 3.59 KB
dist - 4 KB
example.example.log - 4 B
node_modules - 4 KB
package-lock.json - 57.46 KB
package.json - 1.77 KB
safe-app-cli.js - 3.38 KB
yarn-error.log - 39.76 KB
ERROR: Error: Dynamic Linking Error: /snapshot/safe-cli-boilerplate/node_modules/@maidsafe/safe-node-app/src/native/mock/libsafe_app.so: cannot open shared object file: No such file or directory
at new DynamicLibrary (/snapshot/safe-cli-boilerplate/node_modules/ffi/lib/dynamic_library.js:74:11)
at Object.DynamicLibrary (/snapshot/safe-cli-boilerplate/node_modules/ffi/lib/dynamic_library.js:33:12)
at Object.ffi.init (/snapshot/safe-cli-boilerplate/node_modules/@maidsafe/safe-node-app/src/native/lib.js:20:15)
at new SAFEApp (/snapshot/safe-cli-boilerplate/node_modules/@maidsafe/safe-node-app/src/app.js:36:9)
at Object.initializeApp (/snapshot/safe-cli-boilerplate/node_modules/@maidsafe/safe-node-app/src/index.js:61:25)
at authorise (/snapshot/safe-cli-boilerplate/safe-app-cli.js:0:0)
at Object.Safe.bootstrap (/snapshot/safe-cli-boilerplate/safe-app-cli.js:0:0)
at __dirname (/snapshot/safe-cli-boilerplate/cli.js:0:0)
at Object. (/snapshot/safe-cli-boilerplate/cli.js:0:0)
at Module._compile (pkg/prelude/bootstrap.js:1243:22)
(node:14503) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Failed to load native libraries: Error: Dynamic Linking Error: /snapshot/safe-cli-boilerplate/node_modules/@maidsafe/safe-node-app/src/native/mock/libsafe_app.so: cannot open shared object file: No such file or directory
(node:14503) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```
@bzee has done some investigation of this and notes:
> Your post did encourage me to dive a little deeper into why the executable built by `pkg` is not able to load the library. I think it has to do with how `node-ffi` works (which is what `safe-node-app` uses to load the SAFE library). `node-ffi` loads the file from disk, with platform specific Dynamic Library functions (LoadLibraryW for Windows).
> ([ref](https://forum.safedev.org/t/how-to-pick-up-openurl-auth-response-in-a-non-electron-desktop-app/1689/12?u=happybeing))
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.