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

I'm here to ask you a very strange problem.

Right now i'm starting to work on Salesforce technology, in windows, and currently i follow the tutorial. When finally arrive to the terminal part, Windows come out to create problem...

I state that I am using the terminal of Git Bash Here (MinTTY)

$ sfdx force:data:record:create -s Account -v "Name='Hilton Union Square' BillingStreet='333 O Farrell St' BillingCity='San Francisco' BillingState='CA' BillingPostalCode='94102' Phone='(415) 771-1400' Website='www.hilton.com'"
"C:\Program" non è riconosciuto come comando interno o esterno,
 un programma eseguibile o un file batch.

More in general, the problem comes out every time there are Quote in the argument:

$ sfdx ""
"C:\Program" non è riconosciuto come comando interno o esterno,
 un programma eseguibile o un file batch.

opposite to:

$ sfdx
Salesforce CLI

VERSION
  sfdx-cli/7.157.0 win32-x64 node-v16.15.1

USAGE
  $ sfdx [COMMAND]

TOPICS
  alias    manage username aliases
  auth     authorize an org for use with the Salesforce CLI
  config   configure the Salesforce CLI
......

I try almost every thing: alias, Path, Full Path, Short Path, Quote, ... this is my current path:

PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/mingw64/bin:/usr/bin:/c/Users/A409806/bin:/c/Program Files/Common Files/Oracle/Java/javapath:/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/WINDOWS/System32/WindowsPowerShell/v1.0:/c/WINDOWS/System32/OpenSSH:/c/Program Files (x86)/WindowsPowerShell/Scripts:/cmd:/c/Program Files/nodejs:/c/Users/A409806/AppData/Local/Microsoft/WindowsApps:/c/Program Files/sfdx/bin:/c/Users/A409806/AppData/Roaming/npm:/c/Users/A409806/AppData/Local/Programs/Microsoft VS Code/bin:/c/Users/A409806/AppData/Local/JetBrains/Toolbox/scripts:/usr/bin/vendor_perl:/usr/bin/core_perl

Please, someone help me, i suppose is MinTTY problem, but i can't immage how solve it.

Thanks agane

Sébastien Dubois / February 13, 2019

2 min read

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

Recently, I’ve lost quite a bit of time figuring why npm scripts would suddenly fail on Windows under Git bash if they tried to execute bash (e.g., "do-something": "bash ./do-something.sh").

I was executing the npm scripts from Git Bash as usual, so of course bash.exe was on my path but, it wasn’t found in the environment tied to the process for the script execution:

‘bash’ is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] clean-assets: `bash ./build.sh clean_assets`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] clean-assets script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

To my surprise, after digging for a while, I’ve realized that the script was executed under cmd.exe.

Apparently, since npm 5, we can select the shell to use by defining the “script-shell” setting in the npm config:

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

After setting this, my problem was directly fixed.

Hope this helps! :)

For reference, I found this related SO question: https://stackoverflow.com/questions/23243353/how-to-set-shell-for-npm-run-scripts-in-windows

That's it for today! ✨

About Sébastien

Hello everyone! I'm Sébastien Dubois. I'm an author, founder, and CTO. I write books and articles about software development & IT, personal knowledge management, personal organization, and productivity. I also craft lovely digital products 🚀

If you've enjoyed this article and want to read more like this, then subscribe to my newsletter, check out my PKM Library and my collection of books about software development 🔥.

You can follow me on Twitter 🐦

If you want to discuss, then don't hesitate to join one of my communities: the Software Crafters community, the Personal Knowledge Management community, and the focusd Productivity community

Get Sébastien's free weekly newsletter. Read by hundreds of people to explore and stay up to date on learning, personal knowledge management, personal organization, software development, and bootstrapping

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

Solution.
Search for "environment variables" in the Windows search bar and open the respective Control Panel item..
A System Properties window will appear. ... .
Edit the PATH environment variable and add the path to the folder where PowerShell is located..
For the changes to be picked up, the agent needs to be restarted..

How do I enable bash on Windows?

Press Windows key + X then click Command prompt, at the command prompt, type: bash then hit Enter. If you want to be able to access the local file system, press Windows key + X, Command Prompt (Admin) then type bash at the prompt.