1

I am attempting to install sodium native as an npm package on OpenBSD 7.3 amd64.

Aside: As a dependency of Hypercore, Hyperbee and Corestore.

This needs node-gyp.

Following this, I set the C and C++ compilers to clang:

export CC=clang
export CXX=clang++

I created a directory example and, for development/debugging only, I set the permissions via chmod 777.

I then used npm init to create an empty package.json file.

On running npm install sodium-native, I get the following error logs:

395 info run [email protected] install node_modules/sodium-native node-gyp-build
396 info run [email protected] install { code: 1, signal: null }
397 timing reify:rollback:createSparse Completed in 4183ms
398 timing reify:rollback:retireShallow Completed in 0ms
399 timing command:install Completed in 31258ms
400 verbose stack Error: command failed
400 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
400 verbose stack     at ChildProcess.emit (node:events:513:28)
400 verbose stack     at maybeClose (node:internal/child_process:1091:16)
400 verbose stack     at Socket.<anonymous> (node:internal/child_process:449:11)
400 verbose stack     at Socket.emit (node:events:513:28)
400 verbose stack     at Pipe.<anonymous> (node:net:322:12)
401 verbose pkgid [email protected]
402 verbose cwd /example
403 verbose OpenBSD 7.3
404 verbose node v18.15.0
405 verbose npm  v9.5.0
406 error code 1
407 error path /example/node_modules/sodium-native
408 error command failed
409 error command sh -c node-gyp-build
410 error gyp info it worked if it ends with ok
410 error gyp info using [email protected]
410 error gyp info using [email protected] | openbsd | x64
410 error gyp info find Python using Python version 3.10.11 found at "/usr/local/bin/python3"
410 error gyp info spawn /usr/local/bin/python3
410 error gyp info spawn args [
410 error gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
410 error gyp info spawn args   'binding.gyp',
410 error gyp info spawn args   '-f',
410 error gyp info spawn args   'make',
410 error gyp info spawn args   '-I',
410 error gyp info spawn args   '/example/node_modules/sodium-native/build/config.gypi',
410 error gyp info spawn args   '-I',
410 error gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
410 error gyp info spawn args   '-I',
410 error gyp info spawn args   '/root/.cache/node-gyp/18.15.0/include/node/common.gypi',
410 error gyp info spawn args   '-Dlibrary=shared_library',
410 error gyp info spawn args   '-Dvisibility=default',
410 error gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.15.0',
410 error gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
410 error gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.15.0/<(target_arch)/node.lib',
410 error gyp info spawn args   '-Dmodule_root_dir=/example/node_modules/sodium-native',
410 error gyp info spawn args   '-Dnode_engine=v8',
410 error gyp info spawn args   '--depth=.',
410 error gyp info spawn args   '--no-parallel',
410 error gyp info spawn args   '--generator-output',
410 error gyp info spawn args   'build',
410 error gyp info spawn args   '-Goutput_dir=.'
410 error gyp info spawn args ]
410 error node:events:491
410 error       throw er; // Unhandled 'error' event
410 error       ^
410 error
410 error Error: write EPIPE
410 error     at WriteWrap.onWriteComplete [as oncomplete] (node:internal/stream_base_commons:94:16)
410 error Emitted 'error' event on Socket instance at:
410 error     at Socket.onerror (node:internal/streams/readable:785:14)
410 error     at Socket.emit (node:events:513:28)
410 error     at emitErrorNT (node:internal/streams/destroy:151:8)
410 error     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
410 error     at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
410 error   errno: -32,
410 error   code: 'EPIPE',
410 error   syscall: 'write'
410 error }
410 error
410 error Node.js v18.15.0
410 error gyp: Call to 'node deps/bin.js --print-include' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
410 error gyp ERR! configure error 
410 error gyp ERR! stack Error: `gyp` failed with exit code: 1
410 error gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:325:16)
410 error gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
410 error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
410 error gyp ERR! System OpenBSD 7.3
410 error gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
410 error gyp ERR! cwd /example/node_modules/sodium-native
410 error gyp ERR! node -v v18.15.0
410 error gyp ERR! node-gyp -v v9.3.1
410 error gyp ERR! not ok
411 verbose exit 1
412 timing npm Completed in 31440ms
413 verbose unfinished npm timer reify 1683196282136
414 verbose unfinished npm timer reify:build 1683196305333
415 verbose unfinished npm timer build 1683196305334
416 verbose unfinished npm timer build:deps 1683196305334
417 verbose unfinished npm timer build:run:install 1683196305349
418 verbose unfinished npm timer build:run:install:node_modules/sodium-native 1683196307572
419 verbose code 1
420 error A complete log of this run can be found in:
420 error     /root/.npm/_logs/2023-05-04T10_31_22_018Z-debug-0.log

The node_modules directory did not get created. I am unsure how to interpret this. It's not clear to me whether its a permissions problem, a compiler toolchain problem, or something else.

What might be going wrong here? What next steps could I take?


EDIT: Further investigation:

The problem can be more directly recreated like so:

pkg_add git
git clone --branch v3.3.0 https://github.com/sodium-friends/sodium-native
pkg_add node
cd s*
node deps/bin.js --print-include --print-lib --print-arch

Using console.logs in deps/bin.js narrows down the problem a socket created on a process object by the run function, when passed 'tar' and 'xzv' arguments (after attempting to fetch libsodium from https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz); when it attempts to pipe between sockets. I saw this, and wonder if there is any reason that OpenBSD might prematurely close the socket?

Possibly relevant links:

https://stackoverflow.com/questions/39739626/what-is-node-gyp https://stackoverflow.com/questions/58436786/build-of-sodium-native-on-centos-cloud-is-failing https://stackoverflow.com/questions/39855232/npm-install-fails-with-node-gyp-build-error https://github.com/prebuild/node-gyp-build/issues/8

https://github.com/nodejs/node-gyp/issues/809


Note: adapted and cross-posted here.

1 Answer 1

0

One can install version 3.2.1 like so:

npm i [email protected]

Prior to this, I had done the following (unsure whether this is required for the above to work as yet):

pkg_add git
git clone --branch v3.2.1 https://github.com/sodium-friends/sodium-native
cd s*
pkg_add libsodium
pkg_add libtool
pkg_add autoconf
export AUTOCONF_VERSION=2.71 #choose your version
pkg_add automake
export AUTOMAKE_VERSION=1.16 #choose your version
npm install
npm test # check it installed ok

Note, this half-solution gives a module that results in error when used with upstream sodium-universal and hypercore modules.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.