Chcp is not recognized as an internal or external command, operable program or batch file

Question:

I am receiving the error message below in the command prompt when using the git init command. I’m using a Windows PC running Windows 7.

C:\rails_projects\first_app>git init

'chcp'isnotrecognized asan internal orexternal command,

operable program orbatchfile.

Reinitialized existing Git repository inC:/rails_projects/first_app/.git/

'chcp'isnotrecognized asan internal orexternal command,

operable program orbatchfile.

I’m new to Ruby on Rails and I’m trying to create a repository for my Rails project. When I use a command such as rails new first_app or rails server I don’t receive the message, only when I used the git init command does it show up. Also, as you can see the command still functions correctly [i.e. Reinitialized existing Git repository in C:/rails_projects/first_app/.git/], however, it’s annoying to see the error message every time I make a command.

Does anyone have any idea how to fix this problem? I found a link that told me I need to switch the console to Windows-1252 //illegalargumentexception.blogspot.com/2009/04/i18n-unicode-at-windows-command-prompt.html#charsets_1252 but that didn’t work.

I appreciate any help, thanks!

Answer:

See if your PATH environment variable is setup properly. Any system should have atleast the below on PATH

;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;

Add the above if not there.

Once added, open a new cmd / bash and try:

It should give the path.

Then try with the git init again

Edit

If you need help to find where to add it

Thanks for at least trying our little experiment out, @MuneebAwan... sorry you found a case we didn't test:

Not much of a windows guy, so i had to google what chcp does, and the problems of it not being found. Sounds like an environment variable problem. If you [or some program on your behalf] has messed about with your %PATH% permanently [robotlab only messes about with it temporarily, we hope], you'll probably have some issues.

I'm betting somebody down in the robotlab stack [who knows, might be me!] is trying to generate some "pretty" output: chcp is some dark magic for changing terminal output, sometimes used to make ANSI/Unicode display.

If the shortcut is not working, can you try the more manual approach of:

  • open a plain old cmd.exe window
  • when the command prompt shows up
    • type c:\users\mm\robotlab\scripts\activate c:\users\mm\robotlab, press enter
    • type robotlab, press enter

That might get you going! We're long overdue on rebuilding this thing, though... perhaps if the stars align we can do some tidying up and get one out!

Hello,

It is pretty strange indeed. Could you please provide the following informations :

  • Is Jenkins running on a x64 system ?
  • Could you run "where chcp" and "where chcp.com" out of Jenkins and inside of Jenkins [using Jenkins script console] ?
  • Could you run "echo %PATH%" inside and outside Jenkins ?

Thanks
Regards
Lionel

Lionel Cabasson added a comment - 2017-02-23 16:21 Hello, It is pretty strange indeed. Could you please provide the following informations : Is Jenkins running on a x64 system ? Could you run "where chcp" and "where chcp.com" out of Jenkins and inside of Jenkins [using Jenkins script console] ? Could you run "echo %PATH%" inside and outside Jenkins ? Thanks Regards Lionel

Hi Lionel,

Yes, the slave runs on a x64 machine [as does the server].
It is Windows 7 64bit, running 64bit java:

java version "1.8.0_121"
Java[TM] SE Runtime Environment [build 1.8.0_121-b13]
Java HotSpot[TM] 64-Bit Server VM [build 25.121-b13, mixed mode]

The slave runs jenkins as a service, and jenkins-slave.exe also seems to be 64bit.

On the slave [directly from the prompt]:

  • "where chcp" -> "C:\Windows\System32\chcp.com"
  • "where chcp.com" -> "C:\Windows\System32\chcp.com"
  • "echo %path%" -> "C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\"

On the slave via script console:

  • "where chcp" -> "C:\Windows\System32\chcp.com"
  • "where chcp.com" -> "C:\Windows\System32\chcp.com"
  • "println System.getenv["PATH"]" -> "C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\"

I could not get "echo %path%" to work via script console.
Please note that i removed some personal info from the path, but both where identical.

I did some further testing, and "chcp" works after i copied "C:\Windows\System32\chcp.com" to "C:\Windows\System32\chcp.exe"

Regards, Roel.

Roel van Nuland added a comment - 2017-02-24 02:01 Hi Lionel, Yes, the slave runs on a x64 machine [as does the server]. It is Windows 7 64bit, running 64bit java: java version "1.8.0_121" Java[TM] SE Runtime Environment [build 1.8.0_121-b13] Java HotSpot[TM] 64-Bit Server VM [build 25.121-b13, mixed mode] The slave runs jenkins as a service, and jenkins-slave.exe also seems to be 64bit. On the slave [directly from the prompt]: "where chcp" -> "C:\Windows\System32\chcp.com" "where chcp.com" -> "C:\Windows\System32\chcp.com" "echo %path%" -> "C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\" On the slave via script console: "where chcp" -> "C:\Windows\System32\chcp.com" "where chcp.com" -> "C:\Windows\System32\chcp.com" "println System.getenv["PATH"]" -> "C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\" I could not get "echo %path%" to work via script console. Please note that i removed some personal info from the path, but both where identical. I did some further testing, and "chcp" works after i copied "C:\Windows\System32\chcp.com" to "C:\Windows\System32\chcp. exe " Regards, Roel.

Hi,

  Some more info:
even after copying

chcp.com

to

chcp.exe

, the v1.27 plugin still produces the same error.

I'm not running the Jenkins slave service as the default user [Local system] but as a dedicated User which is part of the Users group.
[I did not yet fiddle with the rights of that user, just a standard new local Windows user].

Might that have something to do with it?

Regards, Roel.

Roel van Nuland added a comment - 2017-03-22 12:47 Hi,   Some more info: even after copying chcp.com to chcp.exe , the v1.27 plugin still produces the same error. I'm not running the Jenkins slave service as the default user [Local system] but as a dedicated User which is part of the Users group. [I did not yet fiddle with the rights of that user, just a standard new local Windows user]. Might that have something to do with it? Regards, Roel.

Hello,

Maybe this user does not have access right to chcp or the user PATH environment variable does not contain its parent forlder.

Could you try running Jenkins with the Local system user for the sake of testing ?

I wanted to wait a little bit to see if there was any other user who encountered the same issue but it seems you're the only one so it's probably an environment specific problem. By the way, I will think about adding an option not to run chcp so that one can disable it if any problem arise.

Regards
Lionel

Lionel Cabasson added a comment - 2017-03-27 06:46 Hello, Maybe this user does not have access right to chcp or the user PATH environment variable does not contain its parent forlder. Could you try running Jenkins with the Local system user for the sake of testing ? I wanted to wait a little bit to see if there was any other user who encountered the same issue but it seems you're the only one so it's probably an environment specific problem. By the way, I will think about adding an option not to run chcp so that one can disable it if any problem arise. Regards Lionel

Hi Lionel,

I've changed the service to run as Local Service now, and it behaves exactly like it did when it ran as a separate user.
I also tried with Local System by reinstalling the service, but this also behaves exactly like it did when it ran as a separate user.

Adding the option to not run chcp would be greatly appreciated.

Regards, Roel.

Roel van Nuland added a comment - 2017-03-27 12:37 Hi Lionel, I've changed the service to run as Local Service now, and it behaves exactly like it did when it ran as a separate user. I also tried with Local System by reinstalling the service, but this also behaves exactly like it did when it ran as a separate user. Adding the option to not run chcp would be greatly appreciated. Regards, Roel.

I'm having this exact problem.  Jenkins 2.46.1 LTS, MSBuild V1.27 on Windows Server 2012 R2 64-bit.  When I downgrade the MSBuild back to V1.26, the problem goes away.

Shawn Baker added a comment - 2017-04-07 13:47 I'm having this exact problem.  Jenkins 2.46.1 LTS, MSBuild V1.27 on Windows Server 2012 R2 64-bit.  When I downgrade the MSBuild back to V1.26, the problem goes away.

Hello Shawn,

Thanks for your feedback, I will try to take some time to do a new release with the following features :

  • an error running chcp should be ignored and not prevent msbuild from running
  • the plugin should provide an option to disable the chcp command

Regards
Lionel

Lionel Cabasson added a comment - 2017-04-11 06:42 Hello Shawn, Thanks for your feedback, I will try to take some time to do a new release with the following features : an error running chcp should be ignored and not prevent msbuild from running the plugin should provide an option to disable the chcp command Regards Lionel

Is this problem resolved?
I can see exact same problem given by Build a Visual Studio project or solution using MSBuild Jenkins plugin in the slave job.

Command:

[Klocwork_CSharp_Project_Builder] $ cmd.exe /C " chcp 1252 && "C:\Program Files [x86]\MSBuild\14.0\bin\MSBuild.exe" /p:Configuration=Release %WORKSPACE%\KWCSharpProjectBuilder.sln " && exit %%ERRORLEVEL%%

Error:

'chcp' is not recognized as an internal or external command,

Ajit Surana added a comment - 2017-09-20 10:06 Is this problem resolved? I can see exact same problem given by Build a Visual Studio project or solution using MSBuild Jenkins plugin in the slave job. Command: [Klocwork_CSharp_Project_Builder] $ cmd.exe /C " chcp 1252 && "C:\Program Files [x86]\MSBuild\14.0\bin\MSBuild.exe" /p:Configuration=Release %WORKSPACE%\KWCSharpProjectBuilder.sln " && exit %%ERRORLEVEL%% Error: 'chcp' is not recognized as an internal or external command,

Code changed in jenkins
User: Marshall
Path:
src/main/java/hudson/plugins/msbuild/MsBuildBuilder.java
src/main/resources/hudson/plugins/msbuild/MsBuildBuilder/config.jelly
//jenkins-ci.org/commit/msbuild-plugin/78cf15892d8411edae8aded2ec13e9b12015c740
Log:
JENKINS-42284 Add an option to prevent chcp from being executed

Since some users encountered an error when the plugin was running chcp
command, this commit add a checkbox on the msbuild step allowing to
prevent the plugin from running it.

SCM/JIRA link daemon added a comment - 2017-10-07 13:45 Code changed in jenkins User: Marshall Path: src/main/java/hudson/plugins/msbuild/MsBuildBuilder.java src/main/resources/hudson/plugins/msbuild/MsBuildBuilder/config.jelly //jenkins-ci.org/commit/msbuild-plugin/78cf15892d8411edae8aded2ec13e9b12015c740 Log: JENKINS-42284 Add an option to prevent chcp from being executed Since some users encountered an error when the plugin was running chcp command, this commit add a checkbox on the msbuild step allowing to prevent the plugin from running it.

SCM/JIRA link daemon added a comment - 2017-10-07 13:45 Code changed in jenkins User: Marshall Path: src/main/java/hudson/plugins/msbuild/MsBuildBuilder.java //jenkins-ci.org/commit/msbuild-plugin/c1b2074190a938099e04b2cae88febee88bf32a8 Log: JENKINS-42284 Improvement of chcp error handling The chcp command no more prevents msbuild from running in case of error. If the command fails, the plugin will still run msbuild so the build can continue.

Hello,

Release 1.28 should solve the issue :

  • chcp errors no longer fail the build. If an error occured, it is ignored and msbuild is run anyway
  • a checkbox has been added on the build step configuration allowing you to prevent the plugin from running chcp [although it should not be necessary since chcp should not fail the build anymore]

Regards
Lionel

Lionel Cabasson added a comment - 2017-10-07 16:15 Hello, Release 1.28 should solve the issue : chcp errors no longer fail the build. If an error occured, it is ignored and msbuild is run anyway a checkbox has been added on the build step configuration allowing you to prevent the plugin from running chcp [although it should not be necessary since chcp should not fail the build anymore] Regards Lionel

Based on the symptoms, the error might have been caused by an incorrect value of the PATHEXT environment variable. The cmd.exe and MSBuild.exe invocations would not have been affected because those include the .exe extension.

Kalle Niemitalo added a comment - 2021-01-09 15:43 Based on the symptoms, the error might have been caused by an incorrect value of the PATHEXT environment variable. The cmd.exe and MSBuild.exe invocations would not have been affected because those include the .exe extension.

How do you fix CHCP is not recognized as an internal or external command?

you can put the file C:\Windows\System32\chcp.com to the folder c:\Program Files\BMC Software\BladeLogic\appserver\NSH\bin ... this solved the problem for me.

How do you fix make is not recognized as an internal or external command operable program or batch file?

You can resolve this issue in three ways: First, use the full path of the executable file to launch the program. Second, add the program path to Windows environment variables. Finally, move the files to the System32 folder.

What is CHCP command?

Changes the active console code page. If used without parameters, chcp displays the number of the active console code page.

Why Java is not recognized as an internal or external command operable program or batch file?

If the \bin directory of the JDK or JRE is not added to the Windows or Linux PATH variable, programs may not be able to find it at runtime. This would certainly cause the “Java not recognized” error, even if the JDK or JRE is properly installed.

Chủ Đề