Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine linux compatibility issue #33

Closed
dennyhong96 opened this issue Jun 25, 2021 · 5 comments
Closed

Alpine linux compatibility issue #33

dennyhong96 opened this issue Jun 25, 2021 · 5 comments

Comments

@dennyhong96
Copy link

dennyhong96 commented Jun 25, 2021

Hi there, we are trying to install uplink-nodejs on an Alpine linux container built with the following Dockerfile.

FROM node:lts-alpine

RUN \
  npm install -g npm@latest && \
  apk update && \
  apk add --no-cache bash g++ make git musl-dev go python3 alpine-sdk && \
  npm i -g node-gyp@7.1.2
/home/node/test2 #  npm i uplink-nodejs

We got an '_Bool' does not name a type Error

The Error
/home/node/test2 # npm i uplink-nodejs
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path /home/node/test2/node_modules/uplink-nodejs
npm ERR! command failed
npm ERR! command sh -c (node-gyp configure) && (node-gyp rebuild)
npm ERR! make: Entering directory '/home/node/test2/node_modules/uplink-nodejs/build'
npm ERR!   CXX(target) Release/obj.target/uplink/libUplink.o
npm ERR! make: Leaving directory '/home/node/test2/node_modules/uplink-nodejs/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/node/test2/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/node/test2/node_modules/uplink-nodejs/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/node/test2/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/14.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/14.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/node/test2/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/14.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/node/test2/node_modules/uplink-nodejs',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/node/test2/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/node/test2/node_modules/uplink-nodejs/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/node/test2/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/14.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/14.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/node/test2/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/14.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/node/test2/node_modules/uplink-nodejs',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../functions/definitions.h:14,
npm ERR!                  from ../libUplink.h:5,
npm ERR!                  from ../libUplink.cc:6:
npm ERR! cgo-gcc-export-header-prolog:124:8: error: '_Bool' does not name a type
npm ERR! cgo-gcc-export-header-prolog:216:8: error: '_Bool' does not name a type
npm ERR! make: *** [uplink.target.mk:125: Release/obj.target/uplink/libUplink.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/home/node/test2/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:375:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Linux 5.10.25-linuxkit
npm ERR! gyp ERR! command "/usr/local/bin/node" "/home/node/test2/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/node/test2/node_modules/uplink-nodejs
npm ERR! gyp ERR! node -v v14.17.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

We solved that error by cloning down the master branch of uplink-nodejs repo, then run make build within it.

/home/node/test2 # git clone https://github.com/storj-thirdparty/uplink-nodejs.git
/home/node/test2 # cd uplink-nodejs/
/home/node/test2/uplink-nodejs # make build

The build was successful, removed the install and preinstall script in package.json to prevent rebuilding when installing as a dependency.

/home/node/test2/uplink-nodejs # cd ../
/home/node/test2 # npm i ./uplink-nodejs

The installation is successful. Copied the HelloStorj.js and try to run it.

/home/node/test2/ # cp ./uplink-nodejs/HelloStorj.js ../
/home/node/test2 # node HelloStorj.js

We got this error Could not locate the bindings file.

The error
/home/node/test2 # ls
HelloStorj.js      node_modules       package-lock.json  package.json       uplink-nodejs
/home/node/test2 # node HelloStorj.js
/home/node/test2/node_modules/bindings/bindings.js:135
  throw err;
  ^

Error: Could not locate the bindings file. Tried:
→ /home/node/test2/uplink-nodejs/build/uplink.node
→ /home/node/test2/uplink-nodejs/build/Debug/uplink.node
→ /home/node/test2/uplink-nodejs/build/Release/uplink.node
→ /home/node/test2/uplink-nodejs/out/Debug/uplink.node
→ /home/node/test2/uplink-nodejs/Debug/uplink.node
→ /home/node/test2/uplink-nodejs/out/Release/uplink.node
→ /home/node/test2/uplink-nodejs/Release/uplink.node
→ /home/node/test2/uplink-nodejs/build/default/uplink.node
→ /home/node/test2/uplink-nodejs/compiled/14.17.1/linux/x64/uplink.node
→ /home/node/test2/uplink-nodejs/addon-build/release/install-root/uplink.node
→ /home/node/test2/uplink-nodejs/addon-build/debug/install-root/uplink.node
→ /home/node/test2/uplink-nodejs/addon-build/default/install-root/uplink.node
→ /home/node/test2/uplink-nodejs/lib/binding/node-v83-linux-x64/uplink.node
at bindings (/home/node/test2/node_modules/bindings/bindings.js:126:9)
at Object. (/home/node/test2/uplink-nodejs/dist/access.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object. (/home/node/test2/uplink-nodejs/dist/uplink.js:5:21)
at Module._compile (internal/modules/cjs/loader.js:1085:14) {
tries: [
'/home/node/test2/uplink-nodejs/build/uplink.node',
'/home/node/test2/uplink-nodejs/build/Debug/uplink.node',
'/home/node/test2/uplink-nodejs/build/Release/uplink.node',
'/home/node/test2/uplink-nodejs/out/Debug/uplink.node',
'/home/node/test2/uplink-nodejs/Debug/uplink.node',
'/home/node/test2/uplink-nodejs/out/Release/uplink.node',
'/home/node/test2/uplink-nodejs/Release/uplink.node',
'/home/node/test2/uplink-nodejs/build/default/uplink.node',
'/home/node/test2/uplink-nodejs/compiled/14.17.1/linux/x64/uplink.node',
'/home/node/test2/uplink-nodejs/addon-build/release/install-root/uplink.node',
'/home/node/test2/uplink-nodejs/addon-build/debug/install-root/uplink.node',
'/home/node/test2/uplink-nodejs/addon-build/default/install-root/uplink.node',
'/home/node/test2/uplink-nodejs/lib/binding/node-v83-linux-x64/uplink.node'
]
}

To get the uplink.node file, we spin up a container using this Dockerfile from your repo and installed the uplink-nodejs in there.

Then in the alpine container, we downloaded the uplink.node into uplink-nodejs/out/Release/ then re-installed as a dependency.

/home/node/test2/  # mkdir -p uplink-nodejs/out/Release
/home/node/test2/ # cd uplink-nodejs/out/Release
/home/node/test2/uplink-nodejs/out/Release # wget https://github.com/rethinksoftware/uplink-nodejs/blob/linux-build/build/Release/uplink.node?raw=true
/home/node/test2/uplink-nodejs/out/Release # mv uplink.node?raw\=true uplink.node
/home/node/test2/uplink-nodejs/out/Release # cd /home/node/test2/
/home/node/test2/ # rm -rf node_modules
/home/node/test2/ # npm install ./uplink-nodejs
/home/node/test2/ # node HelloStorj.js

After installation. We got this error initial-exec TLS resolves to dynamic definition in /home/uplink/libuplinkcv1.2.4.so trying to run the HelloStorj.js example

The Error
/home/node/test2 # ls
HelloStorj.js      node_modules       package-lock.json  package.json       uplink-nodejs
/home/node/test2 # node HelloStorj.js
/home/node/test2/node_modules/bindings/bindings.js:121
        throw e;
        ^

Error: Error relocating /home/uplink/libuplinkcv1.2.4.so: (null): initial-exec TLS resolves to dynamic definition in /home/uplink/libuplinkcv1.2.4.so
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at bindings (/home/node/test2/node_modules/bindings/bindings.js:112:48)
at Object. (/home/node/test2/uplink-nodejs/dist/access.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)

We think it's related to an ongoing bug when using cgo, and want to bring it to your attention. Is there anything you recommend trying?

@Erikvv
Copy link

Erikvv commented Jun 29, 2021

I am able to get beyond this point but I get a NAPI error when downloading.

https://github.com/storj-thirdparty/uplink-js works for me on Linux.

@dennyhong96
Copy link
Author

dennyhong96 commented Jul 1, 2021

I am able to get beyond this point but I get a NAPI error when downloading.

https://github.com/storj-thirdparty/uplink-js works for me on Linux.

Does uplink-js work on Alpine Linux for you? When I installed it on an Alpine container built with

FROM node:lts-alpine

RUN \
  npm install -g npm@latest && \
  apk update && \
  apk add --no-cache bash g++ make git musl-dev go python3 alpine-sdk && \
  npm i -g node-gyp@7.1.2

It gives me this error

The Error
npm ERR! Cloning into 'uplink-c'...
npm ERR! Note: switching to '496683529b9328761d8398fa57a0e23215e45d9f'.
npm ERR!
npm ERR! You are in 'detached HEAD' state. You can look around, make experimental
npm ERR! changes and commit them, and you can discard any commits you make in this
npm ERR! state without impacting any branches by switching back to a branch.
npm ERR!
npm ERR! If you want to create a new branch to retain commits you create, you may
npm ERR! do so (now or later) by using -c with the switch command. Example:
npm ERR!
npm ERR!   git switch -c 
npm ERR!
npm ERR! Or undo this operation with:
npm ERR!
npm ERR!   git switch -
npm ERR!
npm ERR! Turn off this advice by setting config variable advice.detachedHead to false
npm ERR!
npm ERR!   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
npm ERR!                                  Dload  Upload   Total   Spent    Left  Speed
100  115M  100  115M    0     0  9555k      0  0:00:12  0:00:12 --:--:-- 10.1M
npm ERR! /bin/sh: /home/up/node_modules/uplink-js/go/bin/go: not found
npm ERR! /bin/sh: /home/up/node_modules/uplink-js/go/bin/go: not found
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/up/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/up/node_modules/uplink-js/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/up/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/14.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/14.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/up/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/14.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/up/node_modules/uplink-js',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@14.17.1 | linux | x64
npm ERR! gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/home/up/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/up/node_modules/uplink-js/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/up/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/14.17.1/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/14.17.1',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/home/up/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/14.17.1/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/up/node_modules/uplink-js',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: *** No rule to make target '/home/up/node_modules/uplink-js/libuplinkc.h', needed by '/home/up/node_modules/uplink-js/build/Release/libuplinkc.h'.  Stop.
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/home/up/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:375:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
npm ERR! gyp ERR! System Linux 5.10.25-linuxkit
npm ERR! gyp ERR! command "/usr/local/bin/node" "/home/up/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /home/up/node_modules/uplink-js
npm ERR! gyp ERR! node -v v14.17.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

@Erikvv
Copy link

Erikvv commented Jul 5, 2021

Yes there seems to be an issue there where it downloads the Go binary but then it isn't at the location where the author intended.

npm ERR! /bin/sh: /home/up/node_modules/uplink-js/go/bin/go: not found

@Erikvv
Copy link

Erikvv commented Jul 6, 2021

I don't know directly how to help out, I hope one of the more regular maintainers can chime in.

@kmozurkewich
Copy link
Member

kmozurkewich commented Jul 29, 2021

Hi @dennyhong96,

I got so far as to get the object file for libuplink, however, it looks like there are numerous compatibility items due to alpine using musl instead of glib.

One core issue is the types seems to be incompatible with cgo:

make: Entering directory '/root/node_modules/uplink-nodejs/build' CXX(target) Release/obj.target/uplink/libUplink.o In file included from ../functions/definitions.h:14, from ../libUplink.h:5, from ../libUplink.cc:6: cgo-gcc-export-header-prolog:124:8: error: '_Bool' does not name a type cgo-gcc-export-header-prolog:216:8: error: '_Bool' does not name a type

I spent some time replacing with Bool from stdbool.h which gets the object to build, however, the binding file still will not build due to:

Error: Error relocating /root/node_modules/uplink-nodejs/libuplinkcv1.2.4.so: (null): initial-exec TLS resolves to dynamic definition in /root/node_modules/uplink-nodejs/libuplinkcv1.2.4.so

We're happy to accept a PR from the community to solve, however will not be prioritizing this item in the near-term, though may revisit in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants