2kai2kai2 / VSCode-Python-Resource-Monitor

A Visual Studio Code extension for viewing resource consumption of Python programs in the debugger.
https://marketplace.visualstudio.com/items?itemName=kaih2o.python-resource-monitor
GNU General Public License v3.0
17 stars 5 forks source link

Extension fails to load, unable to install node-ps-data #7

Closed mgrunbauer closed 1 year ago

mgrunbauer commented 1 year ago

Hello, when installing the extension (v0.2.0) from the marketplace and starting a debug session, the extension does not show up.

Mac OS 13.3.1 with Apple M1 chip

Output from "Extension Host" logging shows it cannot install node-ps-data:

Output from `Output > Extension Host` logging

``` 2023-04-29 19:36:21.524 [error] Activating extension kaih2o.python-resource-monitor failed due to an error: 2023-04-29 19:36:21.524 [error] Error: Cannot find module 'node-ps-data' Require stack: - /Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/out/extension.js - /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js - /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-amd.js - /Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js - at Module._resolveFilename (node:internal/modules/cjs/loader:987:15) at i._resolveFilename (node:electron/js2c/utility_init:17:840) at Module._load (node:internal/modules/cjs/loader:832:27) at c._load (node:electron/js2c/asar_bundle:5:13343) at m._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:124:14199) at h._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:119:11871) at I._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:119:11264) at Module.require (node:internal/modules/cjs/loader:1059:19) at g (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:647) at Object. (/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/out/extension.js:14:12) at u._compile (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1220:10) at Module.load (node:internal/modules/cjs/loader:1035:32) at Module._load (node:internal/modules/cjs/loader:876:12) at c._load (node:electron/js2c/asar_bundle:5:13343) at m._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:124:14199) at h._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:119:11871) at I._load (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:119:11264) at Module.require (node:internal/modules/cjs/loader:1059:19) at require (node:internal/modules/cjs/helpers:102:18) at Function.i [as __$__nodeRequire] (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/loader.js:5:98) at E.rb (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:119:13135) at async Promise.all (index 0) ```

Manually running npm install reveals it is missing a header file:

Output of `npm install`

``` myusername@myusername-mbp kaih2o.python-resource-monitor-0.2.0 % npm install npm WARN deprecated @npmcli/move-file@1.1.2: This functionality has been moved to @npmcli/fs npm WARN deprecated vscode-test@1.6.1: This package has been renamed to @vscode/test-electron, please update to the new name npm ERR! code 1 npm ERR! path /Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-ps-data npm ERR! command failed npm ERR! command sh -c node-gyp-build npm ERR! CXX(target) Release/obj.target/node_ps_data/napi.o npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@8.4.1 npm ERR! gyp info using node@19.9.0 | darwin | arm64 npm ERR! gyp info find Python using Python version 3.11.3 found at "/opt/homebrew/opt/python@3.11/bin/python3.11" npm ERR! gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/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 '/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-ps-data/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/Users/myusername/Library/Caches/node-gyp/19.9.0/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=/Users/myusername/Library/Caches/node-gyp/19.9.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/Users/myusername/Library/Caches/node-gyp/19.9.0/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-ps-data', 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! ../napi.cc:2:10: fatal error: 'napi.h' file not found npm ERR! #include npm ERR! ^~~~~~~~ npm ERR! 1 error generated. npm ERR! make: *** [Release/obj.target/node_ps_data/napi.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 (/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-gyp/lib/build.js:194:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:513:28) npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12) npm ERR! gyp ERR! System Darwin 22.4.0 npm ERR! gyp ERR! command "/opt/homebrew/Cellar/node/19.9.0/bin/node" "/Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/.bin/node-gyp" "rebuild" npm ERR! gyp ERR! cwd /Users/myusername/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0/node_modules/node-ps-data npm ERR! gyp ERR! node -v v19.9.0 npm ERR! gyp ERR! node-gyp -v v8.4.1 npm ERR! gyp ERR! not ok npm ERR! A complete log of this run can be found in: /Users/myusername/.npm/_logs/2023-04-29T18_06_26_341Z-debug-0.log ```

However I can manually compile node-ps-data. So I can get the extension to work by:

Any thoughts?

PS. after working around the installation issues, the plugin does show up in vs code when debugging on MacOS :). It shows very high memory values (>300 GB) but that might be a different issue.

mgrunbauer commented 1 year ago

If it helps, I have a similar issue on Linux where it cannot find node-ps-data after installing the extension. However simply running npm install in the extension directory worked for me without locally building node-ps-data like I had on Mac OS.

This might be unrelated, as I'm using Code OSS on Linux and I couldn't find your extension in the marketplace somehow. So I've had to install it manually by downloading from vsixhub, it might not trigger the npm install because of that?

rongardF commented 1 year ago

I'm having the same issue, but on Linux. @mgrunbauer can you please clarify, after you manually cloned and built the extension, then you edited package.json in ~/.vscode/extensions/kaih2o.python-resource-monitor-0.2.0 right? Did you edit the section dependencies.node-ps-data ? I have there some version number (1.3.0) right now, so I should replace that?

mgrunbauer commented 1 year ago

@rongardF correct. To clarify, I did the following steps to work around the installation issue:

rongardF commented 1 year ago

Thanks for the clarification. I did all the steps, but for me it is still not showing up. However, I'm running my app in dev container, so maybe that's the issue?

mgrunbauer commented 1 year ago

I have no experience with dev containers so I cannot comment on that.

To help rule out what is causing the issue you are seeing, maybe you could try starting a debug session for a simple python file without running it in a dev container?

Also maybe some extra info is shown in the Output > Extension Host logging.

rongardF commented 1 year ago

Okay, thanks, I'll give it a try!

2kai2kai2 commented 1 year ago

Apologies for the late reply, the most recent version just released (v0.2.2) should resolve this by packaging some node-modules with the extension. Tested on Windows and Linux.