0

I'm seeing some discrepancies between commands I execute on my plain old OS terminal (I'm using a Mac) and the terminal that ships with IntelliJ (the version I'm using is Ultimate 2019.2).

For one thing, Maven isn't recognized in IntelliJ, even though I've set the Maven home directory correctly in the IntelliJ settings to /opt/apache-maven-3.6.0 instead of the bundle that ships with IntelliJ. I've also ensured that the JDK in IntelliJ is set to /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/bin/java.

OS terminal:

$ which java
/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/bin/java

$ which mvn
/opt/apache-maven-3.6.0/bin/mvn

$ mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T13:41:47-05:00)
Maven home: /opt/apache-maven-3.6.0
Java version: 1.8.0_211, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"

IntelliJ terminal:

$ which java
/usr/bin/java

$ mvn -v
bash: mvn: command not found

Can someone explain these discrepancies?

Paul Erdos
  • 1,355
  • 2
  • 23
  • 47
  • Have you already restarted the terminal in intellij or opened a new one after installation? – CodeMatrix Aug 20 '19 at 20:11
  • See https://stackoverflow.com/a/26586170/104891. Depending on how you set the environment on macOS it may be not visible to the GUI applications. Try running IntelliJ IDEA from the same terminal with `/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea` and see if it helps. – CrazyCoder Aug 20 '19 at 20:15
  • The PATH when running in IntelliJ terminal is different from the PATH when running in OS terminal. Look at the path. Look at the IntelliJ settings. Look at your init scripts, e.g. some of the bash scripts like `/etc/profile`, `/etc/bash.bashrc`, `~/.bash_profile`, `~/.bash_login`, `~/.profile`, `~/.bashrc` – Andreas Aug 20 '19 at 20:16

1 Answers1

0

I solved this issue using a suggestion from this post (the third suggestion from @Kyle Strand). In the terminal settings in IntelliJ, I set the shell path for Bash to run in interactive mode using -i. I'm now using the same $PATH as my OS terminal and Maven command line is now recognized.

Paul Erdos
  • 1,355
  • 2
  • 23
  • 47