version-fox / vfox

A cross-platform and extendable version manager with support for Java, Node.js, Flutter, .Net & more
https://vfox.lhan.me
Apache License 2.0
2.52k stars 84 forks source link

[BUG]: Unable to run "npm" after "vfox use nodejs" in Git Bash #293

Open colececil opened 1 month ago

colececil commented 1 month ago

Version vfox 0.5.3 (installed using scoop) OS Windows 11

Describe the bug After running vfox use nodejs in Git Bash, I can execute node, but I get a "No such file or directory" error if I try to execute npm. After looking inside the directory mentioned in the error message, I did find that if I instead run npm.cmd, it works.

Example

$ vfox use nodejs
Please select a version of nodejs:
  -> 20.13.1
Now using nodejs@20.13.1.
$ node --version
v20.13.1
$ npm --version
/bin/bash: C:/Users/colec/.version-fox/temp/1716613200-1047/nodejs/npm: No such file or directory
$ ls -al /c/Users/colec/.version-fox/temp/1716613200-1047/nodejs/
total 67896
drw-rw-rw-  3 colec 0     4096 2024-05-25 21:58 .
drw-rw-rw-  3 colec 0        0 2024-05-25 21:58 ..
-rw-rw-rw-  1 colec 0    55087 2024-05-25 21:58 CHANGELOG.md
-rw-rw-rw-  1 colec 0      334 2024-05-25 21:58 corepack
-rwxrwxrwx  1 colec 0      218 2024-05-25 21:58 corepack.cmd
-rwxrwxrwx  1 colec 0     3033 2024-05-25 21:58 install_tools.bat
-rw-rw-rw-  1 colec 0   119618 2024-05-25 21:58 LICENSE
-rwxrwxrwx  1 colec 0 69266072 2024-05-25 21:58 node.exe
drw-rw-rw-  4 colec 0        0 2024-05-25 21:58 node_modules
-rwxrwxrwx  1 colec 0      702 2024-05-25 21:58 nodevars.bat
-rw-rw-rw-  1 colec 0     2073 2024-05-25 21:58 npm
-rwxrwxrwx  1 colec 0      538 2024-05-25 21:58 npm.cmd
-rw-rw-rw-  1 colec 0     2073 2024-05-25 21:58 npx
-rwxrwxrwx  1 colec 0      538 2024-05-25 21:58 npx.cmd
-rw-rw-rw-  1 colec 0    39557 2024-05-25 21:58 README.md
$ npm.cmd --version
10.5.2
aooohan commented 1 month ago

I have not reproduced this issue.

image
colececil commented 1 month ago

@aooohan Is there anything I can do to help find a way to reproduce the issue? I tried it on a different Windows machine, and I get the issue there too. Though interestingly, the error message is different there, and it seems to be coming from WSL (see the command line output below). Also, I'm not sure if this would make a difference, but on both of these machines, I have gow installed via Scoop.

$ vfox use nodejs
Please select a version of nodejs:
  -> 20.14.0
Now using nodejs@20.14.0.
$ which node
C:\Users\colec\.version-fox\temp\1716872400-1847\nodejs\node.EXE
$ node --version
v20.14.0
$ which npm
C:\Users\colec\.version-fox\temp\1716872400-1847\nodejs\npm
$ npm --version
<3>WSL (10) ERROR: CreateProcessParseCommon:711: Failed to translate C:\Users\colec
<3>WSL (10) ERROR: CreateProcessParseCommon:757: getpwuid(0) failed 2
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\.version-fox\temp\1716872400-1847\nodejs
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\.version-fox\temp\1716872400-2608\nodejs
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\System32\OpenSSH
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Git\usr\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files (x86)\Intel\iCLS Client
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Intel\iCLS Client
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\system32
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\System32\Wbem
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\System32\WindowsPowerShell\v1.0
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\ProgramData\chocolatey\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files (x86)\GtkSharp\2.12\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\system32
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\System32\Wbem
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\System32\WindowsPowerShell\v1.0
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\System32\OpenSSH
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Docker\Docker\resources\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\scoop\apps\vscodium\current\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\go\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\scoop\apps\volta\current\appdata\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\scoop\shims
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Ruby22-x64\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\AppData\Local\Microsoft\WindowsApps
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Microsoft VS Code\bin
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\tools\cmder
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Aseprite
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\AppData\Local\JetBrains\Toolbox\scripts
<3>WSL (10) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\colec\repos\familiar.sh
Processing fstab with mount -a failed.
Failed to mount C:\, see dmesg for more details.
Failed to mount G:\, see dmesg for more details.

<3>WSL (10) ERROR: CreateProcessEntryCommon:334: getpwuid(0) failed 2
<3>WSL (10) ERROR: CreateProcessEntryCommon:505: execvpe /bin/bash failed 2
<3>WSL (10) ERROR: CreateProcessEntryCommon:508: Create process not expected to return
$ which npm.cmd
C:\Users\colec\.version-fox\temp\1716872400-1847\nodejs\npm.cmd
$ npm.cmd --version
10.7.0
colececil commented 1 month ago

@aooohan I discovered that, interestingly, I don't have this issue with Node.js <= v15.11.0.

image

yanecc commented 2 weeks ago

我使用vfox-clang插件在git-bash中复现了这个问题,而在powershell中能够正常工作

Sunrise@Yane MINGW64 /c/WINDOWS/system32
$ clang --version
bash: clang: command not found

Sunrise@Yane MINGW64 /c/WINDOWS/system32
$ clang.bat --version
clang version 18.1.7
Target: x86_64-pc-windows-msvc
Thread model: posix

在powershell中

PS C:\Users\Sunrise> clang --version
clang version 18.1.7
Target: x86_64-pc-windows-msvc
Thread model: posix