首页 > 解决方案 > 将 gitbash 添加到 windows cmd 以运行 make 文件

问题描述

我有一台安装git在上面的 Windows 机器。在安装时我检查了add the gitbash to environment但安装后当我ls在我的 Windows cmd 中运行一个 smiple 命令时我得到了错误

'ls' is not recognized as an internal or external command,
operable program or batch file.

现在这是我窗户上的环境变量

在此处输入图像描述

第二个是 git 在安装时自动添加的,但我通过搜索堆栈溢出来添加第一个,但它们似乎都不起作用。

额外细节

万一你想知道它给我带来了什么麻烦。我正在运行一些可以在我的设备上make正常运行的命令,gitbash但在我的 goland 终端上却出现了这个错误

./scripts/fmt.sh provider
process_begin: CreateProcess(NULL, sh C:\Users\farsh\go\src\gojeh\scripts\fmt.sh provider, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:16: run] Error 2

标签: windowsbashgit

解决方案


TL;博士

适用于 Windows 的 Git 故意只在您的 Windows PATH 上设置最低限度

细节

如果您查看git\bin目录,您会看到只有git,bash并且sh在那里。然后有一个git\usr\bin目录将是您期望的标准 *nix 风格的实用程序,包括ls,虽然不包括make在我的机器上。这些不会添加到您的 Windows 路径中,因为它们中的许多会与标准的 Windows 实用程序冲突,并且隐藏它们可能会对 Windows 中运行的其他东西产生不可预测的影响。

所以你会发现额外的东西只有在你在 Git Bash 内部运行时才可见,它们应该以 *nix 方式工作。

如果您make的系统需要,您可能应该安装一个打算在 Windows 上使用的版本。


推荐阅读