MATLAB: Simulink model build is failing in Windows with the error ” ‘C:/Window​s/System32​/bash.exe’ is not recognized as an internal or external command “

Embedded Coder

I am using Simulink to deploy code on Pixhawk 4 hardware. I am working in Windows 10, build 16299, version 1703. When I hit the ‘Deploy to hardware’ button in Simulink, the Diagnostic Viewer mentions that a separate command prompt will be launched for building. I do see a command prompt being launched. However, after a few seconds an error is reported in diagnostic viewer that the PX4 firmware build has failed and check the build log in the PX4 firmware folder.
The build log contains the following information:
'C:/Windows/System32/bash.exe' is not recognized as an internal or external command, operable program or batch file.
MW_BUILD_COMPLETE
How do I fix this issue?

Best Answer

If your Windows 10 build version is less than 17134, a separate command prompt is launched where the output of PX4 firmware compilation is displayed. If any error occurs during compilation, the error is logged in log file MWPX4Buildlog.txt in the PX4 firmware folder.
If one of the following errors are seen in the log file,
'C:/Windows/System32/bash.exe' is not recognized as an internal or external command, operable program or batch file.
'C:/Windows/Sysnative/bash.exe' is not recognized as an internal or external command, operable program or batch file.
it can be resolved by executing the below command in MATLAB command window:
>> setpref('MW_PX4_WSLBuildPath','SwitchPath', 1)
Try building the model again after running the above command.
For more information, refer to this link: