IntelliJ IDE - cannot run Maven from terminal inside IDE (path is set) - bash

last week I got new laptop from company so I had to do new installation from scratch.
I installed my JDK, Maven, git bash and IDE, configured environment variables for MAVEN_HOME and JAVA_HOME... added them to Path with for example: %JAVA_HOME%\bin and same for maven.
Both JDK and Maven work perfectly fine with cmd and git bash or even with maven plugin in IntelliJ.
But if i want to open terminal inside of IDE and run some maven command it will give me mvn not found error.
I use /wanna use git bash, but it gives same error for cmd inside of IDE as well.
I've checked terminal system environemtns setting in IDE and I can find MAVEN_HOME inside and I even tried to add M2_HOME but error is the same (I do reset terminal after every change).
Also, in git bash if I write echo $PATH it will return me my variables as it can be seen here:
/mingw64/bin:/usr/bin:/c/Users/user.name/bin:/c/Program Files (x86)/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/Docker/Docker/resources/bin:/c/ProgramData/DockerDesktop/version-bin:%JAVA_H
OME%/bin:%MAVEN_HOME%/bin:/cmd:/c/Users/prese/AppData/Local/Microsoft/WindowsApps:/c/Users/username/AppData/Local/Programs/Microsoft VS Code/bin:/c/Program Files/herok
u/bin
I never had an issue like this as usually all I had to do after installig java/maven and git bash was to change default terminal in IDE to git bash.... and that's it.
But something is different this time around.
Please do share what can I do and/or try.
EDIT:
If I write:
export PATH=$PATH:/c/Program\ Files/Apache\ Maven/apache-maven-3.6.3/bin
This will set maven and it will work... but only for this instance of terminal... new instace and session will not have it

Related

Gradle miss environment variable when running tasks from IntelliJ IDA in WSL

I'm working on a Gradle project with multiple sub modules. Some of these are using maven. Thus one Gradle task is running maven from the MAVEN_HOME directory. This task is called by IntelliJ IDEA during Gradle refresh. When running IntelliJ Community Edition 2021.1 on an Ubuntu 20_05 VM, everything works fine. When running the same version of IntelliJ Windows with WSL 2, the task fails with error
MAVEN_HOME environment variable not set, unable to locate mvn executable for build
When I open a shell in WSL, I see that the MAVEN_HOME is actually set. I've defined it in my ~/.profile file. I can build my project from the terminal command line. IntelliJ IDEA uses the Gradle wrapper for building the project. It uses the shebang #!/bin/env sh. So it is not opening a login shell und thus the ~/.profile files are not read.
Any ideas how to solve this problem?

cmd cannot find mvn command

I just installed Maven and added the \bin directory of maven to my path variables. When I try to use the mvn command in the Command Prompt I just get a message:
mvn: command not found
Everything else I found on here did not help yet.
Edit:
I used https://maven.apache.org/install.html to install maven.
SET PATH=%PATH%;C:\Program Files\Maven\apache-maven-3.5.0\bin\mvn.cmd
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
You have included the file in the path:
C:\Program Files\Maven\apache-maven-3.5.0\bin\mvn.cmd
That is not good. The PATH environment variable should only include a path to where files, like exe and cmd's can be found.
Adapt your PATH to read like this:
C:\Program Files\Maven\apache-maven-3.5.0\bin
(so remove the \mvn.cmd). Make sure to start a new command prompt to verify if your path settings are correct.
See How can I set user environmental variables (such as PATH) from a non-administrator account on Windows 7 to find the correct Windows dialog to adapt the settings among many more.
Following this tutorial by mkyong, I was able to get this to work on Windows 10 (v10.0.15063):
Install JDK and setup JAVA_HOME system variable
Download Maven zip, extract it and setup M2_HOME and MAVEN_HOME system variables to point to root maven folder (without \bin)
Update PATH system variable to include %M2_HOME%\bin (this is what will let you run "mvn" in Command Prompt).
Open Command Prompt (cmd.exe) and execute mvn -version
You can download Maven (apache-maven-3.5.0-bin.zip) here, if you don't have it already.
The Java SDK (jdk-8u144-windows-x64.exe) can be downloaded from Oracle here.
This is my working maven configuration on Windows 10. Was more cumbersome to configure on W10 than on WXP or W7.
I've faced the same problem. I installed Maven and added the \bin directory of maven to my path variables in System Variables, so I can only use MAVEN commands using admin rights (run cmd in windows as administrator)
I solved this by creating all under User variables (including the PATH variable).

Git is not recognized in pycharm

I am trying to pull a github repository from bitbucket using pyCharm.
I added the path to my git executable under version control / Git and installed the bitbucket plugin. If I test both it says the test are running fine.
However when I open the terminal now and try to pull a rep like this:
git pull https://marcvanderpeet1983#bitbucket.org/marcvanderpeet1983/betfair_predictions.git
I get the following error:
'git' is not recognized as an internal or external command,
operable program or batch file.
Any thoughts on what goes wrong here?
The terminal has nothing to do with those options you have set. The terminal just forwards your commands to the operation system, in your case Windows. You have to add the path to git.exe in your PATH environment variable, log out and log back into windows to be able to use git from cmd.exe or the terminal you are trying to use.
The setting in PyCharm is just for the Git integration, so that PyCharm can use Git. So if you use the PyCharm GUI and menues to use Git, then the setting is used and works. And I guess with the BitBucket plugin you get additional GUI options for cloning, pull-requests and so on, but I don't konw as I don't use the BitBucket.
I had to close ALL of my PyCharm windows and then reopen the project for the updated system path to take effect in the PyCharm terminal.
I had a problem like this, Git suddenly stopped working and not recognized in PyCharm, I fixed this issue by in PyCharm:
go to file > sitting > Plugins
search for Git and GitHub and check them
restart PyCharm
Git will work and be recognized again.
Thanks
While integrating PyCharm Community with my GitHub account, I found that following these two steps worked for me (on Windows).
Download Git separately from here
Changing Paths: Type Environment Variable in the start menu -> Select Environment Variable at the bottom -> Under System Variables Double-click Path -> In the new popped window click New -> Add C:\Program Files\Git\cmd & C:\Program Files\Git\bin\ at the bottom of the list
Restart system after closing all running apps > reopen PyCharm

IntelliJ terminal setup

I used to run gradle test via IntelliJ terminal with following command,
>gradle test Accidentally I deleted my windows path environmental variable in my windows 7 machine.
After this when I run above command I get below error
'gradle' is not recognized as an internal or external command,
operable program or batch file.
What should I add in path environmental variable to get this run again
IntelliJ version 13.0.3
I added all java and gradle path under env. variable (I can run test via cygwin with above command)
Thanks
This issue was resolved after restarting the windows. Because after adding path to the env variable and restart IntelliJ was not enough.
I should have done this before posting the question.
Please bear with me if any convenience caused.
Cheers

How do I get Netbeans 7.3.1 to see my environment variables on Mac OS X (10.8.3)?

I'd like to run Netbeans from the launcher and get it to see environment variables.
Background:
I'm using netbeans for a rails project and have configured my devel database with configurations using environment variables.
Unfortunately Netbeans appears unable to read those variables even when I list them in /etc/profile (for all users).
I can explicitly run Netbeans from the terminal: /Applications/NetBeans/NetBeans\ 7.3.1.app/Contents/MacOS/netbeans and that gets things to work but I'd much rather run it from
the launcher if I can solve this problem.
You could define them in
/etc/launchd.conf
and restart system. See this for example
If you run NetBeans from the command line, e.g.
open
/Applications/NetBeans/NetBeans 8.1.app/Contents/Resources/NetBeans/bin/netbeans
then the environment variables defined in the shell initialization script will be visible in the NetBeans application. If you start NetBeans via the icon, the initialization scripts are not run.

Resources