microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
161.9k stars 28.45k forks source link

/Users/user/Library/pnpm/pnpm: line 16: exec: node: not found #221787

Closed andriustbol closed 4 weeks ago

andriustbol commented 1 month ago

Type: Bug

Whenever trying to commit or switching between branches VSC throws this error.

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
/Users/user/Library/pnpm/pnpm: line 16: exec: node: not found
husky - pre-commit hook exited with code 127 (error)
husky - command not found in PATH=/Library/Developer/CommandLineTools/usr/libexec/git-core:/Users/user/Library/pnpm:/opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/user/Library/Python/3.9/bin:/Users/user/opt/sonar-scanner-5.0.1.3006-macosx/bin

Already tried suggestions from these threads, but they did not help:

  1. https://github.com/microsoft/vscode/issues/148903
  2. https://github.com/jest-community/vscode-jest/issues/741
  3. https://github.com/jest-community/vscode-jest/issues/526

VS Code version: Code 1.91.1 (Universal) (611f9bfce64f25108829dd295f54a6894e87339d, 2024-06-11T21:02:41.372Z) OS version: Darwin arm64 23.4.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Apple M1 Pro (10 x 2400)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|2, 3, 3| |Memory (System)|16.00GB (0.57GB free)| |Process Argv|--crash-reporter-id 273854ef-0074-4dcd-8e0d-8ba404e1a6d7| |Screen Reader|no| |VM|0%|
Extensions (20) Extension|Author (truncated)|Version ---|---|--- vscode-tailwindcss|bra|0.12.0 npm-intellisense|chr|1.4.5 vscode-markdownlint|Dav|0.55.0 vscode-eslint|dba|3.0.10 vscode-axe-linter|deq|4.9.0 vscode-html-css|ecm|2.0.10 prettier-vscode|esb|10.4.0 vscode-jest-runner|fir|0.4.73 auto-rename-tag|for|0.1.10 react-component-tree|Hab|1.1.1 debugpy|ms-|2024.6.0 isort|ms-|2023.10.1 python|ms-|2024.8.1 vscode-versionlens|pfl|1.14.2 vs-code-prettier-eslint|rve|6.0.0 html5-boilerplate|sid|1.1.1 sapling|tea|1.2.0 gitblame|wad|11.0.1 pretty-ts-errors|Yoa|0.5.4 markdown-all-in-one|yzh|3.6.2
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelc:31048052 dsvsc021:30996838 da93g388:31013173 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 impr_priority:31094925 refactort:31093865 pythonrstrctxtcf:31093870 ```
VSCodeTriageBot commented 1 month ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.91.1. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

lszomoru commented 1 month ago

@andriustbol, it looks like your git repository has some git hooks defined that rely on pnpm being available on the path. Git will respect the environment variables that are available in the "environment" in which code.exe was started. How do you launch VS Code? Is pnpm on the path in the window where you start VS Code from?

andriustbol commented 1 month ago

How do you launch VS Code?

I launch it from the dock panel or `Machintosh HD > Applications > Visual Studio Code.app

Is pnpm on the path in the window where you start VS Code from?

Opening Terminal in VSC after launching it and typing pnpm results in: /Users/user/Library/pnpm/pnpm: line 16: exec: node: not found. However I am using NVM, so I need to do nvm use to set the defined versions, and then pnpm works fine in Terminal. Unfortunately this does not resolve the issue when switching between branches, or making commit, it throws this:

Screenshot 2024-07-16 at 14 56 14

"husky": "8.0.3"

.husky/post-checkout

bash
#!/usr/bin/env sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
. "$(dirname -- "$0")/_/husky.sh"

nvm use

But it works just fine if I open Terminal, navigate to my project dir, type nvm use, and then code ..

lszomoru commented 4 weeks ago

But it works just fine if I open Terminal, navigate to my project dir, type nvm use, and then code ..

Thanks for trying this out, and confirming this. As mentioned, the git process that is spawned by VS Code for every source control operation inherits the "environment" from VS Code, which is the "environment" in which VS Code was launched. At the moment the only solution is to launch VS Code from an "environment" where everything is initialized that is necessary for the git hooks.