5

I installed Apache ant using the link http://www.mkyong.com/ant/how-to-install-apache-ant-on-windows/

I am trying to build my files in git bash.
It shows the following error when I type ant:

bash:ant:command not found

I want to use cd build command.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Sheena Agrawal
  • 700
  • 1
  • 7
  • 15
  • Have you added all the environment variables, as specified at the page you are referring to? If so, can you check that `PATH` variable contains the path to the Ant binary directory? BTW, the page you refer to explains how to use Ant under plain windows, not from bash. – Alexander Kogtenkov Feb 08 '16 at 06:04
  • yes, i added all the environment variables that were required. – Sheena Agrawal Feb 08 '16 at 06:46

1 Answers1

5

Check your PATH when you are in the bash session.

echo $PATH

Don't forget that, after updating the PATH as mentioned in your link (through the Environment variable control panel), you need to open a new CMD session and launch git-bash.exe in order for that session to inherit the modified PATH.

cd c:\path\to\git
git-bash.exe
echo $PATH

The OP confirms in the comment that the PATH is now:

d/Users/h169717/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin/:/mingw32/bin:/us‌​‌r/bin:/d/Users/h169717/bin:/c/Program Files/apache-ant-1.9.6/bin:/c/Program Files/Java/jre1.8.0_72/bin:/c/Program Files/apache-ant-1.9.6/bin:/usr/bin/vendor_perl:/usr/bin/core_perl

And ant is working.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • the path is /d/Users/h169717/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin/:/mingw32?bin:/usr/bin:/d/Users/h169717/bin:/c/ProgramData/Oracle/Java/javapath:/c/Program Files/Java:/usr/bin/vendor_perl:/usr/bin/core_perl – Sheena Agrawal Feb 08 '16 at 06:10
  • @SheenaAgrawal Then you did not add `%ANT_HOME%\bin` in your PATH as mentioned in your link. Do that, open a new windows, launch git-bash in it and check back if the issue persists. – VonC Feb 08 '16 at 06:12
  • open a simple CMD, go to your git installation folder and type git-bash.exe – VonC Feb 08 '16 at 06:16
  • I added %ANT_HOME%\bin in the path. But the path remains the same /d/Users/h169717/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin/:/mingw32?bin:/us‌​r/bin:/d/Users/h169717/bin:/c/ProgramData/Oracle/Java/javapath:/c/Program Files/Java:/usr/bin/vendor_perl:/usr/bin/core_perl – Sheena Agrawal Feb 08 '16 at 06:35
  • OK, what does echo $PATH return now? – VonC Feb 08 '16 at 06:36
  • and in the new window. when i type git-bash.exe it says bash: git-bash.exe: command not found – Sheena Agrawal Feb 08 '16 at 06:38
  • Did you go first where git is installed? – VonC Feb 08 '16 at 06:38
  • echo $PATH returns /d/Users/h169717/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin/:/mingw32/bin:/us‌r/bin:/d/Users/h169717/bin:/c/Program Files/apache-ant-1.9.6/bin:/c/Program Files/Java/jre1.8.0_72/bin:/c/Program Files/apache-ant-1.9.6/bin:/usr/bin/vendor_perl:/usr/bin/core_perl – Sheena Agrawal Feb 08 '16 at 06:42