-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
npm install commands fail on Android 8 - os.cpus() returns undefined #1798
Comments
I should also note, other os methods seem to work ok. > os.arch()
'arm64'
> os.release()
'4.4.56-g594d847d09a1'
> os.platform()
'android'
> os.type()
'Linux' |
Well, the wrapper function is rather simple, so I'm not sure if this will help, but you can try this test script: const cpuValues = new Float64Array(6 * process.binding("util").pushValToArrayMax);
function f(){console.log(arguments);}
console.log(process.binding("os").getCPUs(f,cpuValues,[]));
console.log(cpuValues); @shannon, I edited this to log the [], as well, so now this should log an Arguments array of cpus, then the [], then an array of numbers, if everything's working. If it lists undefined instead of one or more of these, it might narrow down the problem a bit. |
@shannon Are you running the latest version of the I tested |
@Quasic I tried this and it outputs the following: (I truncated all the 0s) $ node test.js
undefined
Float64Array [
0,
0,
0,
...
] @fornwall yes I tried version 8.9.1 and 9.2.0. Both result in the same issue. I just got this phone last week and I haven't done anything in termux yet so I don't think it was anything I did. I even uninstalled an reinstalled termux to see if it would resolve it. I did notice that my os.arch() says "arm64" and not "aarch64" but I assume this is ok. |
Just for the record, it's working in mine, which is
$ node --version |
So I tried it on my wife's Pixel XL (not 2) and I get the same error. os.arch()
"arm64"
os.release()
"3.18.52-g99dda0323132" $ node --version |
@shannon You could see if "callback" is logged (should be on the first line) and see if the 0s are all replaced by -1 when running this: const L=6 * process.binding("util").pushValToArrayMax;
const cpuValues = new Float64Array(L);
for(var i=0;i<L;i++)cpuValues[i]=-1;
function f(){console.log("callback");console.log(arguments);}
console.log(process.binding("os").getCPUs(f,cpuValues,[]));
console.log(cpuValues); I think the native function is basically acting empty. |
@Quasic This script outputs all -1 now so it does seem to be calling the callback. I found a similar bug reported against freebsd here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221762 It seems that if the something doesn't work in libuv it might get be causing it to returned undefined. I don't think the patch provided in that bug applies here but it could give us a lead. I don't really know how to go about testing this functionality in libuv though. |
I seem to be running into the same issue on my Pixel 2 running Node v.8.9.1.
Anything I can do to help diagnose? |
@shannon, the -1 test was to verify that it wasn't changing the Float64Array. The callback should log the word "callback" if it is called. I found that the Windows variant apparently used to return -1 ?? before nodejs/node-v0.x-archive@9557020 |
@Quasic oh sorry I misread what you wrote. "callback" is NOT output so you are correct. node test.js
undefined
Float64Array [
-1,
-1,
-1,
-1,
... |
The patch attached to the last post of the bugzilla report looks promising... |
@shannon, @brianppoole Is this on Android Nougat or Oreo? https://github.com/nodejs/node/blob/master/deps/uv/src/unix/linux-core.c uses /proc/stat to retrieve the cpu info, which means termux/termux-app#299 could apply here. |
@Quasic, yea this is on Oreo 8.0.0. That looks like the problem alright :-/ |
termux/termux-packages#1798 There must be a better workaround?
thanks @Quasic I've opened an issue here npm/npm#19170. It would be good if npm worked without relying on this functionality or gracefully handled the lack of it. I was able to workaround the issue myself by changing |
I made a PR that falls back to 1, but hopefully someone who knows the code will know a better way. |
npm using the current node-worker-farm won't fail, but it will disable concurrent workers. I started patching libuv, which requires more /proc/stat info be mapped to Android sources than just virtual cpu number. If it works, maybe we could use proot or something to generate /proc/stat? I also have perhaps a less ambitious option, in case this doesn't work, suggested at node-worker-farm. |
This comment was marked as spam.
This comment was marked as spam.
It was reported in npm/npm#19170 |
Thanks @shannon, I did what you did. But I changed: |
Same error on Pixel 2 device and both stable and current versions of NodeJs. Patching farm.js works for now but obviously is not a good solution... |
Why npm still is not fixed!!? |
The |
This error is related to unreadable If I copy this file from another device (PC) and bind it with proot, then
var os = require("os")
console.log(os.cpus())
$ node test.js
undefined
$ proot -b ./stat:/proc/stat node test.js
[ { model: 'unknown',
speed: 442,
times:
{ user: 244133600,
nice: 133850200,
sys: 106562200,
idle: 688676200,
irq: 17337100 } },
{ model: 'unknown',
speed: 442,
times:
{ user: 267435300,
nice: 146015100,
sys: 81513800,
idle: 106183200,
irq: 5393300 } } ] |
This problem still exist but I think if you use yarn instead of npm and clone node-red from github the it work, just trying this now do will update you all once I've confirmed |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Closing since |
I don't know if this a node issue or a termux issue but I figured I would start here.
If I install nodejs via
pkg install nodejs
whenever I run npm commands I get an errorAfter reviewing the logs I tracked the error down to this line in a npm dependency.
It seems that os.cpus() returns undefined. I confirmed this using the node command prompt.
I also tried nodejs-current but no luck. Could this be an issue with termux?
The text was updated successfully, but these errors were encountered: