apache / apache/openwhisk-wskdebug
optional dependency `cpu-features` install error
- Dominant language
- JavaScript
- Stars
- 7
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
## Investigation
Even though `cpu-features` is an optional dependency, I'm not sure why it is installed. Doesn't seem to affect anything AFAIK. The error is because `python@2` is no longer included in macOS Monterey 12.3 or greater: https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes#Python
I'm using nodejs-14 with npm@6, so it is not because of the automatic install of optional dependencies of npm@7.
## Workaround
To get rid of this error, users have to either:
1. install python v2 manually: https://www.python.org/downloads/release/python-2713/
2. symlink an existing python@3 (may cause issues): https://dev.to/malwarebo/how-to-set-python3-as-a-default-python-version-on-mac-4jjf
3. Configure their python for node-gyp (after installing python@3): https://github.com/nodejs/node-gyp#configuring-python-dependency
## Fix
Dependency tree:
```
$ npm ls cpu-features
└─┬ @openwhisk/wskdebug@1.4.0
└─┬ dockerode@3.3.1
└─┬ docker-modem@3.0.3
└─┬ ssh2@1.10.0
└── UNMET OPTIONAL DEPENDENCY cpu-features@0.0.4
```
Make sure this optional dependency is not installed, somehow. This will require a fix in the dependencies of wskdebug, not wskdebug itself.
## Error Log and Repro Steps
Click to see...
```
$ mkdir npm-init-test
$ cd npm-init-test
$ npm init -y
Wrote to /Users/shaz/Desktop/tmp/npm-init-test/package.json:
{
"name": "npm-init-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
$ npm install @openwhisk/wskdebug
> cpu-features@0.0.4 install /Users/shaz/Desktop/tmp/npm-init-test/node_modules/cpu-features
> node buildcheck.js > buildcheck.gypi && node-gyp rebuild
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_linux_or_android.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_arm_linux_or_android.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_mips_linux_or_android.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_ppc_linux.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_freebsd.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_linux_or_android.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_macos.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_windows.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/filesystem.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/stack_line_reader.o
CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/string_view.o
LIBTOOL-STATIC Release/cpu_features.a
env: python: No such file or directory
make: *** [Release/cpu_features.a] Error 127
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/shaz/.nvm/versions/node/v14.19.2/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:285:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/Users/shaz/.nvm/versions/node/v14.19.2/bin/node" "/Users/shaz/.nvm/versions/node/v14.19.2/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/shaz/Desktop/tmp/npm-init-test/node_modules/cpu-features
gyp ERR! node -v v14.19.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
> ssh2@1.10.0 install /Users/shaz/Desktop/tmp/npm-init-test/node_modules/ssh2
> node install.js
CXX(target) Release/obj.target/sshcrypto/src/binding.o
SOLINK_MODULE(target) Release/sshcrypto.node
Succeeded in building optional crypto binding
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN npm-init-test@1.0.0 No description
npm WARN npm-init-test@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: cpu-features@0.0.4 (node_modules/cpu-features):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: cpu-features@0.0.4 install: `node buildcheck.js > buildcheck.gypi && node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ @openwhisk/wskdebug@1.4.0
added 124 packages from 102 contributors and audited 126 packages in 27.081s
15 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
```
Contributor guide
Research direction
Trace the reported dependency chain from @openwhisk/wskdebug through dockerode, docker-modem, ssh2, and cpu-features; no repository file is named in the issue. Reproduce npm install on macOS Monterey or newer and determine whether the dependency chain can avoid installing cpu-features; done means installation no longer triggers the Python 2/node-gyp error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100