`exec: "cmd": executable file not found in %PATH%` when compiling for ESP32

I'm using Arduino 1.8.19 with the Arduino system loaded into the Microsoft One Cloud. and running from there. I'm trying to compile the camera example with AI-thinker ESP32 cam. The error I get is :
exec: "cmd": executable file not found in %PATH%
Error compiling for board AI Thinker ESP32-CAM.

I checked the path and cmd.exe is in multiple places including windows/system

OK, well if you ever decide to give Arduino IDE 2.x another try and still have the problem with the hang on startup, feel free to post here and I'll take a look.

It wasn't clear to me, did you make sure one of those places is in the PATH environment variable?

CMD was in the PATH variable and I even added some more paths but nothing worked.

I'm going to ask you to provide some additional information that might allow us to determine the cause of the problem.

:exclamation: NOTE: These instructions will not solve the problem. They are only intended to possibly gather some more information about the problem, which might provide a clue that leads to a solution.

Please do this:

  1. Select File > Preferences from the Arduino IDE menus.
  2. Check the box next to "Show verbose output during: ☐ compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.
  5. After the compilation fails you'll see a button on the right side of the orange bar in the Arduino IDE: Copy error messages. Click that button.
    This copies the full output to the clipboard.
  6. Open a forum reply here by clicking the Reply button.
  7. Click the </> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block
  8. Press Ctrl+V.
    This will paste the compilation output into the code block.
  9. Move the cursor outside of the code tags before you add any additional text to your reply.
  10. Click the Reply button to post the output.

C:\Program Files\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files\Arduino\hardware -hardware C:\Users\Laptop\AppData\Local\Arduino15\packages -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -tools C:\Users\Laptop\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\Laptop\Documents\Arduino\libraries -fqbn=esp32:esp32:d1_mini32:FlashFreq=80,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600 -vid-pid=1A86_7523 -ide-version=10819 -build-path C:\Users\Laptop\AppData\Local\Temp\arduino_build_891502 -warnings=all -build-cache C:\Users\Laptop\AppData\Local\Temp\arduino_cache_489061 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.riscv32-esp-elf-gcc-gcc8_4_0-esp-2021r2.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32-elf-gcc-gcc8_4_0-esp-2021r2.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-gcc8_4_0-esp-2021r2.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.esptool_py.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.1.0 -prefs=runtime.tools.esptool_py-3.1.0.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.1.0 -prefs=runtime.tools.mklittlefs.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mkspiffs.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -verbose C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\ESP32\examples\ESPNow\Multi-Slave\Master\Master.ino
C:\Program Files\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files\Arduino\hardware -hardware C:\Users\Laptop\AppData\Local\Arduino15\packages -tools C:\Program Files\Arduino\tools-builder -tools C:\Program Files\Arduino\hardware\tools\avr -tools C:\Users\Laptop\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files\Arduino\libraries -libraries C:\Users\Laptop\Documents\Arduino\libraries -fqbn=esp32:esp32:d1_mini32:FlashFreq=80,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600 -vid-pid=1A86_7523 -ide-version=10819 -build-path C:\Users\Laptop\AppData\Local\Temp\arduino_build_891502 -warnings=all -build-cache C:\Users\Laptop\AppData\Local\Temp\arduino_cache_489061 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.riscv32-esp-elf-gcc-gcc8_4_0-esp-2021r2.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32-elf-gcc-gcc8_4_0-esp-2021r2.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-gcc8_4_0-esp-2021r2.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2 -prefs=runtime.tools.esptool_py.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.1.0 -prefs=runtime.tools.esptool_py-3.1.0.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\3.1.0 -prefs=runtime.tools.mklittlefs.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mkspiffs.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -verbose C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\libraries\ESP32\examples\ESPNow\Multi-Slave\Master\Master.ino
Using board 'd1_mini32' from platform in folder: C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.1
Using core 'esp32' from platform in folder: C:\Users\Laptop\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.1
cmd /c if exist "C:\\Users\\Laptop\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.5\\libraries\\ESP32\\examples\\ESPNow\\Multi-Slave\\Master\\partitions.csv" COPY /y "C:\\Users\\Laptop\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.5\\libraries\\ESP32\\examples\\ESPNow\\Multi-Slave\\Master\\partitions.csv" "C:\\Users\\Laptop\\AppData\\Local\\Temp\\arduino_build_891502\\partitions.csv"
exec: "cmd": executable file not found in %PATH%
Error compiling for board WEMOS D1 MINI ESP32.


Hi @byronas.

The ESP32 boards platform must have access to the Windows command processor cmd.exe. This error indicates that you have a strange configuration on your computer that somehow does not give access to this essential tool.

Please do this and then comment here to tell me what you find:

  1. Right click the "Start" icon on the left side of the Windows taskbar
  2. Select "System" from the menu.
  3. Click the "Advanced system settings" link you find under the "Related Settings" section of the "Settings" window.
  4. If you get a "User Account Control" dialog, click the Yes button.
  5. In the "System Properties" window, select the "Advanced" tab.
  6. Click the Environment Variables button.

An "Environment Variables" dialog will now open. Look at the list under the "System variables" section of the dialog.

Do you see a variable on the list named "ComSpec"?

I solved this by going back to ver 1.04 in the ESP library.

Thanks for your input but COMSPEC is alive and well, and pointed at, among the 'variables'. I can program several Arduinos, an STM32F103RB but not the ESP32-WROOM-32 board. So at least for the time-being, I will try the ESP route mentioned in the posting above. Incidentally, the path to the variables does not work (although I got there) which shows that not all W10's are the same.

It is relatively rare for boards platforms to use cmd. It is used only in cases where some logic is needed in the command, as you see done here:

Thanks for letting me know. Which specific step or steps in my instructions is incorrect on your system?

The 'not-finding' of cmd /c happens at, what I believe to be, the start of the compilation of the 'blink' example. Anyway, I have also tried to download the ESP toolchain which, after ~700MB of download, exits with 'Code 1'. This appears to be something to do with 'xcopy' that the W10 'Command Prompt' does not have! So, I cannot even use that. Thanks for all your help - Joe.

Perhaps a little light can now be shone on 'cmd.exe' not working; in 'Command Prompt'. If I requested 'set %path%' all the path variables were listed but right at the end, C:\windows\system32\cmd.exe appears with the tag 'Not defined' immediately after it. And that was it, and I must apologise for being so stupid, I had 'cmd.exe' on the end of both 'comspec' and 'path' which is not allowed! Thanks for all your help and I am now able at last to program all three boards - Arduinos, STM32s and ESP32s via the Arduino IDE.

1 Like

Excellent work on finding the problem! Thanks for taking the time to share your findings. That is very interesting. I will be sure to keep this in mind for reports from other users who are having problem with Arduino IDE accessing cmd.

I seems not to get how it works still..

Hello sir i am facing some issues while compiling the sketch for esp32 board. The error is as below
Arduino: 1.8.19 (Windows 7), Board: "DOIT ESP32 DEVKIT V1, 80MHz, 921600, None, Disabled"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Dell\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Dell\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Dell\Documents\Arduino\libraries -fqbn=esp32:esp32:esp32doit-devkit-v1:FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none -vid-pid=10C4_EA60 -ide-version=10819 -build-path C:\Users\Dell\AppData\Local\Temp\arduino_build_530869 -warnings=none -build-cache C:\Users\Dell\AppData\Local\Temp\arduino_cache_163790 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool_py.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.2.1 -prefs=runtime.tools.esptool_py-4.2.1.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.2.1 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.mkspiffs.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.riscv32-esp-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.mklittlefs.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.openocd-esp32.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\openocd-esp32\v0.11.0-esp32-20220706 -prefs=runtime.tools.openocd-esp32-v0.11.0-esp32-20220706.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\openocd-esp32\v0.11.0-esp32-20220706 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -verbose C:\Users\Dell\Desktop\sketch_jan14a\sketch_jan14a.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Dell\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Dell\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Dell\Documents\Arduino\libraries -fqbn=esp32:esp32:esp32doit-devkit-v1:FlashFreq=80,UploadSpeed=921600,DebugLevel=none,EraseFlash=none -vid-pid=10C4_EA60 -ide-version=10819 -build-path C:\Users\Dell\AppData\Local\Temp\arduino_build_530869 -warnings=none -build-cache C:\Users\Dell\AppData\Local\Temp\arduino_cache_163790 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.esptool_py.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.2.1 -prefs=runtime.tools.esptool_py-4.2.1.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.2.1 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32s2-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s2-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.mkspiffs.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.mkspiffs-0.2.3.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mkspiffs\0.2.3 -prefs=runtime.tools.riscv32-esp-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.riscv32-esp-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\riscv32-esp-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.mklittlefs.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.mklittlefs-3.0.0-gnu12-dc7f933.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\mklittlefs\3.0.0-gnu12-dc7f933 -prefs=runtime.tools.openocd-esp32.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\openocd-esp32\v0.11.0-esp32-20220706 -prefs=runtime.tools.openocd-esp32-v0.11.0-esp32-20220706.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\openocd-esp32\v0.11.0-esp32-20220706 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -prefs=runtime.tools.xtensa-esp32s3-elf-gcc-gcc8_4_0-esp-2021r2-patch5.path=C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\gcc8_4_0-esp-2021r2-patch5 -verbose C:\Users\Dell\Desktop\sketch_jan14a\sketch_jan14a.ino

Using board 'esp32doit-devkit-v1' from platform in folder: C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6

Using core 'esp32' from platform in folder: C:\Users\Dell\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6

cmd /c if exist "C:\Users\Dell\Desktop\sketch_jan14a\partitions.csv" COPY /y "C:\Users\Dell\Desktop\sketch_jan14a\partitions.csv" "C:\Users\Dell\AppData\Local\Temp\arduino_build_530869\partitions.csv"

exec: "cmd": executable file not found in %PATH%

Error compiling for board DOIT ESP32 DEVKIT V1.

please help me to resolve it

Yes sir i am able to see " ComSpec"

please tell the next steps
Thanks

Hi @pawanbacchak. The value of the ComSpec environment variable should be some path. For example, on my computer the value is C:\Windows\system32\cmd.exe. Use Windows "File Explorer" to check whether the file cmd.exe is located at the path indicated by the value of the ComSpec environment variable.

Sir i request you to please tell the complete steps for resolving the issue

The complete steps:

  1. Find out why the executable file cmd is not found in %PATH%.
  2. Fix the problem that is causing the executable file cmd to not be found in %PATH%.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.