paixaop / node-sodium

Port of the lib sodium encryption library to Node.js
MIT License
351 stars 126 forks source link

Does not compile on Linux ARM. #175

Open iSuslov opened 2 years ago

iSuslov commented 2 years ago

This package has source of libsodium v1.0.16. This version does not compile on Linux ARM. To be precise, it compiles, but fails on test pwhash_scrypt. See https://github.com/jedisct1/libsodium/issues/721 I can confirm that issue is NOT related to memory. libsodium v1.0.17 and libsodium v1.0.18 has this test fixed. This package needs to be updated to contain updated version of libsodium.. Or archived

alexsoyes commented 2 years ago

Same here... Did you manage to find a solution? 😕

iSuslov commented 2 years ago

@alexsoyes yes, unfortunately I can not change dependencies in the project, so I downloaded this package to a folder outside my of project, substituted libsodium sources with the latest version and created a link to this package with 'yarn link'. It works now on my M1 computer.

jedisct1 commented 2 years ago

@paixaop Any chance you could release an updated version using libsodium-2.0.18-stable?

If not, I guess the only option left is to fork the project.

alexsoyes commented 2 years ago

@iSuslov , pretty cool solution I was not thinking about... clever! Thank you!

I used the same approach but without updating libsodium, I would rather use the one from the OS.

Here is an extract from my Dockerfile if it can help someone.

RUN apt install -y libsodium-dev

RUN mkdir -vp /app/pre-build-node_modules/sodium/deps/build/lib/
RUN mkdir -vp /app/pre-build-node_modules/sodium/deps/build/lib/

RUN ln -s /usr/lib/aarch64-linux-gnu/libsodium.so.23.3.0 /app/pre-build-node_modules/sodium/deps/build/lib/libsodium.so
RUN ln -s /usr/lib/aarch64-linux-gnu/libsodium.a /app/pre-build-node_modules/sodium/deps/build/lib/libsodium.a

RUN cd pre-build-node_modules/sodium && yarn link && cd ../..
RUN yarn link sodium
RUN yarn install
RubenNL commented 1 year ago

I just got the same error. No idea if related, but this is my workaround, also in Docker:

RUN mkdir node_modules
RUN git clone https://github.com/paixaop/node-sodium.git node_modules/sodium
RUN sed -i '/make -j3 check/d' node_modules/sodium/Makefile
#Do not use NPM ci here, only install.
RUN npm install

Warning: This disables the tests, which might not be what you want.

jedisct1 commented 1 year ago

I still would highly recommend using libsodium-1.0.18-stable instead of an obsolete version.

If only because performance is much better.