Windows 10: bash: behat: command not found error

4.8k Views Asked by At

When I run behat -v (or any other Behat command) in Git bash I get the following error

bash: behat: command not found

It works fine in the Windows command prompt.

I've tried installing Git with different options such as 'Use Git from Git Bash only', 'Use Git from the Windows Command Prompt', 'Use MinTTY', 'Use Windows default console window', but nothing has worked.

I installed Behat version 3.2.2 local to a project using Composer.

Does anybody know how to fix this?

2

There are 2 best solutions below

6
On

You need to run Behat from the location where is installed.

Navigate to the folder the Behat is installed (this should contain bin, vendor, composer.json etc) then open a command line there (any will do bash or cmd) and run Behat from there.

Use command for bash:

bin/behat -dl

Or for cmd:

bin\behat -dl

One last thing to check. Find your git shortcut, right click and check Properties->Shortcut tab and in the target you should have something like this:

"C:\Program Files (x86)\Git\bin\sh.exe" --login -i

Close and reopen git console and it should work.
To find the shortcut search git from start and then right click on Git Bash and click open file location.

3
On

As mentioned in "INSTALLING BEHAT (WINDOWS 7)", make sure your %PATH% environment variable includes C:\Behat\bin in your CMD shell session.
And <path\to\Git>\bin (which includes bash.exe)

Then in that same shell, type bash: check that behat works.