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

Error when doing npm install #307

Closed
weixingsun opened this Issue Jun 8, 2016 · 14 comments

Comments

Projects
None yet
5 participants
@weixingsun

weixingsun commented Jun 8, 2016

Hi termux experts,

I am facing an installation issue when doing my experiments: npm i bufferutil --save
node-gyp 3.3.1 was installed successfully by npm install -g node-gyp

$uname -a
Linux localhost 3.4.0-g09a22c6 #1 SMP PREEMPT Wed Apr 20 00:06:25 UTC 2016 armv7l Android
app: termux , linux 3.4.0-g1680ab8 in android 6.0.1
gcc: 6.1.0
make: 4.2
node v6.2.1
npm v3.9.5
node-gyp v3.3.1

Command to reproduce:
npm i bufferutil --save

Is it lacking of kerberos lib: libkrb5-dev ?

npm.install.txt

@fornwall

This comment has been minimized.

Show comment
Hide comment
@fornwall

fornwall Jun 19, 2016

Contributor

The formatting got messed up here. Could you:

  1. Write the command(s) to reproduce the problem (be sure to run apt update && apt upgrade first, so that you are running with updated packages)?
  2. Paste the output of uname -a here?
Contributor

fornwall commented Jun 19, 2016

The formatting got messed up here. Could you:

  1. Write the command(s) to reproduce the problem (be sure to run apt update && apt upgrade first, so that you are running with updated packages)?
  2. Paste the output of uname -a here?
@clausreinke

This comment has been minimized.

Show comment
Hide comment
@clausreinke

clausreinke Jul 3, 2016

I ran into this when trying to npm install node-sass. You should try running your install with verbose options, to see the full command behind SOLINK. If you see both -shared -rdynamic and -pie in the linker flags, have a look at the commit discussion here.

Workaround (if this is the issue): find your ~/.node-gyp/<version>/include/node/common.gypi, remove -pie from ldflags for android builds (for a better approach, see discussion). That should allow addon linking to proceed again..

clausreinke commented Jul 3, 2016

I ran into this when trying to npm install node-sass. You should try running your install with verbose options, to see the full command behind SOLINK. If you see both -shared -rdynamic and -pie in the linker flags, have a look at the commit discussion here.

Workaround (if this is the issue): find your ~/.node-gyp/<version>/include/node/common.gypi, remove -pie from ldflags for android builds (for a better approach, see discussion). That should allow addon linking to proceed again..

@weixingsun

This comment has been minimized.

Show comment
Hide comment
@weixingsun

weixingsun Jul 5, 2016

@clausreinke Thank you for your solution, I am able to build bufferutil module on my Nexus 7 2013 Android 6 now. Have you commit your fix ? so that we don't need to change the flags manually.
Btw, I was caught a bad cold for recent days, sorry for my late response.

weixingsun commented Jul 5, 2016

@clausreinke Thank you for your solution, I am able to build bufferutil module on my Nexus 7 2013 Android 6 now. Have you commit your fix ? so that we don't need to change the flags manually.
Btw, I was caught a bad cold for recent days, sorry for my late response.

@clausreinke

This comment has been minimized.

Show comment
Hide comment
@clausreinke

clausreinke Jul 5, 2016

I've asked the original committer to test and apply a fix, as it is his code, and i've got no experience with node-gyp. I suggest to follow that commit discussion to see when this issue is fixed.

clausreinke commented Jul 5, 2016

I've asked the original committer to test and apply a fix, as it is his code, and i've got no experience with node-gyp. I suggest to follow that commit discussion to see when this issue is fixed.

@fornwall

This comment has been minimized.

Show comment
Hide comment
@fornwall

fornwall Aug 30, 2016

Contributor

@clausreinke What is the best way forward here? Should we try using a patch in the node package in termux, and then trying to get it upstream?

Contributor

fornwall commented Aug 30, 2016

@clausreinke What is the best way forward here? Should we try using a patch in the node package in termux, and then trying to get it upstream?

@rafis

This comment has been minimized.

Show comment
Hide comment
@rafis

rafis Sep 3, 2016

No, no. After I've created simple JavaScript script to test:

var sqlite = require('sqlite3');

And it throws an error:

module.js:568
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: dlopen failed: cannot locate symbol "uv_close" referenced by "/data/data/com.termux/files/home/project/node_modules/sqlite3/lib/binding/node-v48-android-arm64/node_sqlite3.node"...
    at Error (native)
    at Object.Module._extensions..node (module.js:568:18)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/data/data/com.termux/files/home/project/www/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)

rafis commented Sep 3, 2016

No, no. After I've created simple JavaScript script to test:

var sqlite = require('sqlite3');

And it throws an error:

module.js:568
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: dlopen failed: cannot locate symbol "uv_close" referenced by "/data/data/com.termux/files/home/project/node_modules/sqlite3/lib/binding/node-v48-android-arm64/node_sqlite3.node"...
    at Error (native)
    at Object.Module._extensions..node (module.js:568:18)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/data/data/com.termux/files/home/project/www/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
@clausreinke

This comment has been minimized.

Show comment
Hide comment
@clausreinke

clausreinke Sep 4, 2016

@fornwall It is a pity that the original committer has gone quiet - the problem is in his commit. It would be simple enough to make a pull request based on my suggested fix, but (1) the nodejs repo has rules which includes testing requirements and (2) might include android-only patches on a best-effort basis, giving no guarantees that a patch might not make things worse for someone else.

I do not currently have a setup for building and testing nodejs itself (or can we do that in termux?-) for/on android and on a supported platform.

clausreinke commented Sep 4, 2016

@fornwall It is a pity that the original committer has gone quiet - the problem is in his commit. It would be simple enough to make a pull request based on my suggested fix, but (1) the nodejs repo has rules which includes testing requirements and (2) might include android-only patches on a best-effort basis, giving no guarantees that a patch might not make things worse for someone else.

I do not currently have a setup for building and testing nodejs itself (or can we do that in termux?-) for/on android and on a supported platform.

@fornwall

This comment has been minimized.

Show comment
Hide comment
@fornwall

fornwall Sep 14, 2016

Contributor

@clausreinke Does this look like the correct patch?

diff -u -r ../node-v6.5.0/common.gypi ./common.gypi
--- ../node-v6.5.0/common.gypi> 2016-08-26 11:27:16.000000000 -0400
+++ ./common.gypi>      2016-09-14 06:35:35.551380791 -0400
@@ -78,7 +78,12 @@
           }],
           ['OS == "android"', {
             'cflags': [ '-fPIE' ],
-            'ldflags': [ '-fPIE', '-pie' ]
+            'ldflags': [ '-fPIE' ],
+            'target_conditions': [
+              ['_type == "executable"', {
+              'ldflags': [ '-pie' ]
+              }]
+           ]
           }],
           ['node_shared=="true"', {
             'msvs_settings': {

We could add it to the nodejs package in Termux, and propose it for inclusion upstream later.

Contributor

fornwall commented Sep 14, 2016

@clausreinke Does this look like the correct patch?

diff -u -r ../node-v6.5.0/common.gypi ./common.gypi
--- ../node-v6.5.0/common.gypi> 2016-08-26 11:27:16.000000000 -0400
+++ ./common.gypi>      2016-09-14 06:35:35.551380791 -0400
@@ -78,7 +78,12 @@
           }],
           ['OS == "android"', {
             'cflags': [ '-fPIE' ],
-            'ldflags': [ '-fPIE', '-pie' ]
+            'ldflags': [ '-fPIE' ],
+            'target_conditions': [
+              ['_type == "executable"', {
+              'ldflags': [ '-pie' ]
+              }]
+           ]
           }],
           ['node_shared=="true"', {
             'msvs_settings': {

We could add it to the nodejs package in Termux, and propose it for inclusion upstream later.

@clausreinke

This comment has been minimized.

Show comment
Hide comment
@clausreinke

clausreinke Sep 14, 2016

@fornwall Looks about right, but there used to be two occurrences (a normal and a debug configuration?).

I tried to guess the syntax from similar stuff elsewhere in the file, and tested it for building packages on termux (on android). If it also works for you building node for termux (android), that would be two good points in favour of this change. If there was a way to run node's testsuite on android, a pull-request should be pretty obvious, as that includes building packages, which is what this issue is all about..

clausreinke commented Sep 14, 2016

@fornwall Looks about right, but there used to be two occurrences (a normal and a debug configuration?).

I tried to guess the syntax from similar stuff elsewhere in the file, and tested it for building packages on termux (on android). If it also works for you building node for termux (android), that would be two good points in favour of this change. If there was a way to run node's testsuite on android, a pull-request should be pretty obvious, as that includes building packages, which is what this issue is all about..

@fornwall

This comment has been minimized.

Show comment
Hide comment
@fornwall

fornwall Sep 14, 2016

Contributor

@clausreinke I realized that patching common.gypi in the nodejs source folder before building, does not affect the file that ends up in ~/.node-gyp/6.5.0/include/node/common.gypi, right? Do you know where that file comes from?

Contributor

fornwall commented Sep 14, 2016

@clausreinke I realized that patching common.gypi in the nodejs source folder before building, does not affect the file that ends up in ~/.node-gyp/6.5.0/include/node/common.gypi, right? Do you know where that file comes from?

@clausreinke

This comment has been minimized.

Show comment
Hide comment
@clausreinke

clausreinke Sep 15, 2016

@fornwall That connection happens when the patch enters the newest release. See this comment, or the gist it links to. Node-gyp fetches those files from https://nodejs.org/download/release/vX.Y.Z/node-vX.Y.Z-headers.tar.gz.

Until then, you need to patch both copies, it seems.

clausreinke commented Sep 15, 2016

@fornwall That connection happens when the patch enters the newest release. See this comment, or the gist it links to. Node-gyp fetches those files from https://nodejs.org/download/release/vX.Y.Z/node-vX.Y.Z-headers.tar.gz.

Until then, you need to patch both copies, it seems.

@fornwall

This comment has been minimized.

Show comment
Hide comment
@fornwall

fornwall Sep 21, 2016

Contributor

@rafis Note that the process.dlopen issue was another problem (#462) that has now been fixed.

Contributor

fornwall commented Sep 21, 2016

@rafis Note that the process.dlopen issue was another problem (#462) that has now been fixed.

@rafis

This comment has been minimized.

Show comment
Hide comment
@rafis

rafis Oct 19, 2016

@fornwall, thank you very much! Now everyhthing works. Only need to fix this issue (I had to mangle common.gypi manually, I havent tried 'target_conditions', I just remove '-pie' from 'ldflags').

rafis commented Oct 19, 2016

@fornwall, thank you very much! Now everyhthing works. Only need to fix this issue (I had to mangle common.gypi manually, I havent tried 'target_conditions', I just remove '-pie' from 'ldflags').

@fornwall

This comment has been minimized.

Show comment
Hide comment
@fornwall

fornwall Feb 7, 2017

Contributor

I don't think this is an urgent issue anymore after switching to clang, as clang only emits a warning when -pie is added needlessly. So I'm closing this issue as the problem is upstream!

Contributor

fornwall commented Feb 7, 2017

I don't think this is an urgent issue anymore after switching to clang, as clang only emits a warning when -pie is added needlessly. So I'm closing this issue as the problem is upstream!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment