sub*_*amX 6 git bash git-bash windows-subsystem-for-linux
我刚刚在我的 Windows 机器上安装了 Git SCM。我的机器之前安装了 Node。我可以在 git bash 中使用 node -v 。但是,为什么我能够在 Git Bash 中而不是在 WSL Bash 中使用 Windows 应用程序。
WSL Bash 内幕-
hello@comp:~$ node -v
Command 'node' not found, but can be installed with:
sudo apt install nodejs
Run Code Online (Sandbox Code Playgroud)
Git Bash 内幕-
hello@comp MINGW64
$ node -v
v12.10.0
Run Code Online (Sandbox Code Playgroud)
WSL 是一个类似于 Linux 的兼容层。你在 WSL 之上运行 Linux 应用程序,他们认为它们在 Linux 上本地运行,而系统调用正在转换为 Windows 操作系统系统调用(WSL2 - 尚未发布 - 是在 Windows 中运行的完整 Linux 内核)。您确实可以通过 /mnt/c/... 访问 Windows 文件,但这就是您在 Windows-Linux 互操作性方面所能期望的全部内容。
另一方面,Git-bash 是一个Windows应用程序——一个运行 Windows 应用程序的外壳。其中一些可能是用 Linux 兼容库(Cygwin)编译的。但他们不必如此。这提供了较少“类似 Linux”的体验,但如果您只需要一些 Linux 命令行工具并且不需要安装成熟的 Linux 可执行文件,这可能是一个很好的折衷方案。
两个“环境”的 PATH 定义不同。检查节点的目录是否显示在 Git bash 上而不是 WSL Bash 上。在两个环境上运行:
echo $PATH
Run Code Online (Sandbox Code Playgroud)