Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

os.arch should be the architecture of the OS not of the process #2862

Closed
joshwilsdon opened this issue Mar 2, 2012 · 9 comments
Closed

os.arch should be the architecture of the OS not of the process #2862

joshwilsdon opened this issue Mar 2, 2012 · 9 comments

Comments

@joshwilsdon
Copy link

In lib/os.js:

exports.arch = function() {
  return process.arch;
};

Which means that on a system that's running a 64 bit kernel but a 32 bit node binary you get:

> os.arch()
'ia32'

when you would have expected 'x64'.

@bnoordhuis
Copy link
Member

You raise a valid point, the problem is that there doesn't seem to be a proper "always correct" fix.

In these troubled times you can have arbitrary combinations of 32 and 64 bits userlands and kernels. Take a system with a 32 bit kernel and a mostly 64 bit userland. How should it be reported? Is it 32 bits or 64 bits? Both? Neither?

Maybe we should scrap os.arch() and process.arch altogether.

@TooTallNate
Copy link

process.arch needs to stay, since it is accurate at least (the arch of the current process' executable). Plus it's very important information for node-gyp to have ;)

@bnoordhuis
Copy link
Member

Okay, that's a good enough reason for me. Let's keep it the way it is.

@ghost
Copy link

ghost commented Mar 2, 2012

The answer for os.arch() is an easy one on windows. And yeah, process.arch is fine but os.arch is pretty useless as is.

@rmustacc
Copy link

rmustacc commented Mar 2, 2012

os.arch() should either refer to the architecture of the underlying Operating System or the list of what is actually supported by the OS, e.g. isainfo on SunOS. Since the latter isn't always knowable, it should probably just describe what the native arch of the kernel is.

@isaacs
Copy link

isaacs commented Mar 2, 2012

Either it needs to be correct, or removed. Reopening for now.

This can't be changed on a stable branch.

@jasnell
Copy link
Member

jasnell commented May 18, 2015

@isaacs ... have there been any updates on this one?

@jasnell
Copy link
Member

jasnell commented May 20, 2015

Doesn't appear to be a bug. Marking as a feature-request. For backwards compatibility, recommend no changes to the current behavior but it may be worthwhile to add a new process.sysarch() API that always returns the arch of the underlying kernel independently of the process arch.

@Fishrock123
Copy link

+1 deprecate os.arch() and add os.sysarch()

devtools-bot pushed a commit to ChromeDevTools/devtools-frontend that referenced this issue Feb 19, 2017
process.arch is based on the architecture which node.js was compiled for,
not necessarily the architecture of the system the node.js process is
currently running in.

I came across this issue while working on buildbot related stuff.

More info:
nodejs/node-v0.x-archive#2862

BUG=none

Review-Url: https://codereview.chromium.org/2698983004
Cr-Original-Commit-Position: refs/heads/master@{#451511}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 250263fa2e293a555c78479e00b5758c2e56d97e
babot pushed a commit to binaryage/dirac that referenced this issue Feb 19, 2017
process.arch is based on the architecture which node.js was compiled for,
not necessarily the architecture of the system the node.js process is
currently running in.

I came across this issue while working on buildbot related stuff.

More info:
nodejs/node-v0.x-archive#2862

BUG=none

Review-Url: https://codereview.chromium.org/2698983004
Cr-Commit-Position: refs/heads/master@{#451511}
MXEBot pushed a commit to mirror/chromium that referenced this issue Feb 20, 2017
process.arch is based on the architecture which node.js was compiled for,
not necessarily the architecture of the system the node.js process is
currently running in.

I came across this issue while working on buildbot related stuff.

More info:
nodejs/node-v0.x-archive#2862

BUG=none

Review-Url: https://codereview.chromium.org/2698983004
Cr-Commit-Position: refs/heads/master@{#451511}
@Trott Trott closed this as completed Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants