0

I am using Windows and Git Bash. My maven command is set in Environment Variables and is able to execute in any directory of my command line.

But I wrote a bash script and it cannot find my mvn command!

Code:

#!/bin/bash
echo $MAVEN_HOME
#export PATH=$PATH:/c/Users/user/Documents/dev/Tools/apache-maven-3.9.1-bin/apache-maven-3.9.1/bin/
parent_dir="/c/Users/user/Documents/Entwicklung"
echo $parent_dir

# Iterate through subdirectories
for dir in "${parent_dir}"/*/; do
  echo "compiling: ${dir}"
  # Execute a command in each subdirectory
  cd "${dir}"
  # Replace "command" with the command you want to execute
  "/c/Users/user/Documents/Entwicklung/Tools/apache-maven-3.9.1-bin/apache-maven-3.9.1/bin/mvn compile"
  "C:\Users\user\Documents\Entwicklung\Tools\apache-maven-3.9.1-bin\apache-maven-3.9.1\bin\mvn compile"
done

As you can see I try to execute the mvn in Style of Windows Path and Style of Linux Path. But Bash is not able to find the command:

./compile-mms_2.sh: line 15: /c/Users/user/Documents/Entwicklung/Tools/apache-maven-3.9.1-bin/apache-maven-3.9.1/bin/mvn compile: No such file or directory
./compile-mms_2.sh: line 16: C:\Users\user\Documents\Entwicklung\Tools\apache-maven-3.9.1-bin\apache-maven-3.9.1\bin\mvn compile: No such file or directory

Like I told before, on the command line I can execute my mvn from any directory!

Someone maybe have an idea or a hint?

tripleee
  • 175,061
  • 34
  • 275
  • 318
MrOT
  • 1
  • The quotes are wrong, you are trying to execute a file named `mvn compile`. Move the `compile` outside the double quotes. – tripleee May 05 '23 at 08:56
  • ... Though if `mvn` is already on your `PATH`, the command can simply be `mvn compile`, with no quotes anywhere. – tripleee May 05 '23 at 08:59

0 Answers0