Search code examples
mavenhomebrewmacos-big-surhomebrew-cask

How to install Maven on OS-Big Sur (ideally w/ homebrew; both docs not working)


I have never had such a hard time in my life doing something like this, I have downloaded and unzipped and set the paths manually, i.e. below:

export M2_HOME=/Users/coolguy/Desktop/apache-maven-3.8.1 
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m -Xmx512m
export PATH=$M2:$PATH

Just as the maven docs illustrate yet continually I get 'maven' not found, even when cd'ing into the bin folder. mvn -ver - I have done this multiple times, and continuously keyword not found.

I'd actually prefer to do it via homebrew, and I have tried that multiple times as well; but continuously the steps do not work. Is this a big sur thing?

cameron@cool-guy-MacBook-Pro ~ % brew install maven

Updating Homebrew...
fatal: Could not resolve HEAD to a revision
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/cask and adoptopenjdk/openjdk).
==> New Casks
trezor-suite
==> Updated Casks
Updated 17 casks.

Warning: No available formula or cask with the name "maven".
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

Any tips greatly appreciated.

Note: My java version is:

java version "11.0.10" 2021-01-19 LTS

UPDATE, 2 more attempts in .bash_profile:

Now, I have .bash_profile as below: (moved folder to apps folder via tutorial).

export M2_HOME=/Applications/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin

Still mvn not found..

Have also tried using just the below:

PATH=/Applications/apache-maven-3.6.3bin:$PATH

Still mvn not found..

Why is this insanely difficult?


Solution

  • Where the M2_HOME, M2 come from, can you ensure maven command exists in the path you added? If you're not familiar with shell PATH, just don't touch it.

    1. Remove all the M2 related variables
    2. Install maven with Homebrew: brew install maven