Open sakulachi8 opened 4 years ago
How are you running mvn -v
? What kind of terminal? Does it work if you do it from VS Code's terminal?
@EricJizbaMSFT from my Mac terminal as well as VSCode terminal. But in both cases serverless function give issue in VS Code
@ejizba, I am getting the same error message "Failed to find "maven", please ensure that the maven bin directory is in your system path." when attempting to create a Java Azure Function in VS Code.
In VS Code terminal, I ran: mvn -version Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\Program Files\apache-maven-3.6.3-bin\apache-maven-3.6.3\bin.. Java version: 11.0.8, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.8 Default locale: en_CA, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" 'cmd' is not recognized as an internal or external command, operable program or batch file.
I also ran: gradle -v
Gradle 6.7.1
Build time: 2020-11-16 17:09:24 UTC Revision: 2972ff02f3210d2ceed2f1ea880f026acfbab5c0
Kotlin: 1.3.72 Groovy: 2.5.12 Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020 JVM: 11.0.8 (Oracle Corporation 11.0.8+10-LTS) OS: Windows 10 10.0 amd64
@daniaghazal i am using MacOS, assuming you are using windowsOS?
@sakulachi8 yes, I am using Windows 10.
I am getting the same error message "Failed to find "maven", please ensure that the maven bin directory is in your system path." when attempting to create a Java Azure Function in VS Code.
PS C:> mvn -version C:\ Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: C:\apache-maven-3.6.3\bin.. Java version: 1.8.0_131, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_131\jre Default locale: en_IN, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" 'cmd' is not recognized as an internal or external command, operable program or batch file.
Azure functions using powershell inside, but maven dont have "mvn.exe" , just "mvn.cmd" .... you can simulate this problem try run mvn -v using powershell terminal
Same problem here with Ubuntu 22.04.1 LTS VSCode says Failed to find "maven", please ensure that the maven bin directory is in your system path when creating Azure function. Same happened with gradle.
Output of mvn -v or mvn -version on vscode terminal and ubuntu terminal: Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /home/rhandy/.sdkman/candidates/maven/current Java version: 17.0.5, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64 Default locale: en_PH, platform encoding: UTF-8 OS name: "linux", version: "5.15.0-56-generic", arch: "amd64", family: "unix"
Output of java -version: openjdk version "17.0.5" 2022-10-18 OpenJDK Runtime Environment (build 17.0.5+8-Ubuntu-2ubuntu122.04) OpenJDK 64-Bit Server VM (build 17.0.5+8-Ubuntu-2ubuntu122.04, mixed mode, sharing)
Output of echo $PATH: /home/rhandy/.sdkman/candidates/springboot/current/bin:/home/rhandy/.sdkman/candidates/maven/current/bin:/home/rhandy/.sdkman/candidates/kotlin/current/bin:/home/rhandy/.sdkman/candidates/gradle/current/bin:/home/rhandy/.sdkman/candidates/ant/current/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/rhandy/.dotnet/tools:/home/rhandy/.dotnet/tools
Restarted the machine, still not fixed
Could you check what terminal VS Code is using? You can find it in your user settings.
I'm wondering if maybe the env.path that the terminal VS Code is using and the env.path variable that node.js child_process
somehow don't match?
Specifically, we use child_process to check for and run maven. From the documentation:
If options.env is set without PATH, lookup on Unix is performed on a default search path search of /usr/bin:/bin
But I noticed that not all of the paths follow that format. I wonder if this is the source of the error?
This is what I found in the settings about what terminal VSCode is using
Is it possible for you to move your maven installation from the /home
directory to usr/bin
?
I can now create java function app with VSCode. I just uninstalled maven through SDKMAN! and installed maven through APT instead. I changed the $MAVEN_HOME path to its newest directory with "export MAVEN_HOME=/usr/share/maven"
I was thinking of creating a symlink for the SDKMAN's maven inside /usr/bin before but I'm not sure it will work. But maven from apt works so no problem. Thanks for the tips!
After running "mvn -v"
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: /opt/apache-maven-3.6.3 Java version: 15, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home Default locale: en_PK, platform encoding: UTF-8 OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
When I create a new Java Function I get this issue, maven and JDK are installed, can anyone please help me out of this. "Failed to find "maven", please ensure that the maven bin directory is in your system path."