';chcp&x27;未被识别为内部或外部命令、可操作程序或批处理文件。在Windows PC上

';chcp&x27;未被识别为内部或外部命令、可操作程序或批处理文件。在Windows PC上,windows,git,command-line,environment-variables,Windows,Git,Command Line,Environment Variables,使用git init命令时,我在命令提示符下收到以下错误消息。我正在使用运行Windows7的Windows PC C:\rails_projects\first_app>git init 'chcp' is not recognized as an internal or external command, operable program or batch file. Reinitialized existing Git repository in C:/rails_projects/

使用
git init
命令时,我在命令提示符下收到以下错误消息。我正在使用运行Windows7的Windows PC

C:\rails_projects\first_app>git init
'chcp' is not recognized as an internal or external command,
operable program or batch file.
Reinitialized existing Git repository in C:/rails_projects/first_app/.git/
'chcp' is not recognized as an internal or external command,
operable program or batch file.
我是RubyonRails新手,我正在尝试为我的Rails项目创建一个存储库。当我使用诸如
railsnewfirst\uapp
railsserver
之类的命令时,我没有收到消息,只有当我使用
gitinit
命令时,消息才会显示出来。此外,正如您所看到的,该命令仍能正常运行(即在C:/rails\u projects/first\u app/.Git/中重新初始化现有的Git存储库),但是,每次我发出命令时都会看到错误消息,这很烦人

有人知道如何解决这个问题吗?我找到了一个链接,告诉我需要将控制台切换到Windows-1252,但没有成功


谢谢你的帮助,谢谢

看起来是同一个问题。链接对如何修复它有一些想法。在链接中,问题是由独立安装的Git和rails造成的。

您已断开PATH(使用SET PATH检查),chcp是内部Windows命令,可在$Windows\system32\dir中找到,请查看PATH环境变量的设置是否正确。任何系统应至少具有以下路径

;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
如果没有,请添加以上内容

添加后,打开新的cmd/bash并尝试:

where chcp
它应该给出路径

然后再次尝试使用
git init

编辑 如果您需要帮助以找到添加位置

转到\RailsInstaller\Git\cmd,然后使用文本编辑器或word pad(通过右键单击文件并选择edit)打开Git(命令提示文件),现在将有两行,如下所示

@chcp %cp_ansi% > nul < nul 
@chcp%cp\u ansi%>nul

@chcp%cp\u oem%>nul

删除这两个文件,然后保存该文件。这应该可以解决问题

我将文件从windows/system32复制到Vmware CLI/bin目录中,该目录为我解决了问题。

这与rails无关,因此我将编辑您的标记。这只是关于windows上的Git。Git与坏环境变量也没有任何共同之处,特别是在XP64的特殊情况下,尽管有正确的路径条目,仍然可能出现错误消息。更多信息:路径的Manojlds语句;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem已在环境变量中;。然而,我仍然有同样的问题。经过一些分析,通过修改python程序指向的批处理文件,问题得到了解决。在该批处理文件中,上述文件必须位于PATH环境中。
@chcp %cp_oem% > nul < nul