33

I did a brew install maven and it resulted in below:

==> Downloading http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.tar.gz
==> Best Mirror http://apache.oss.eznetsols.org/maven/binaries/apache-maven-3.0.4-bin.tar.gz

curl: (22) The requested URL returned error: 404
Error: Download failed: http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.tar.gz

At first I thought it is a mirror problem with my network. But I changed to another network, and it is still the same. And still the same error after 4 days. I wonder if others are affected.

What should I do to install maven with brew?

1
  • The selected answer is clearly not the best as it is version specific (and tedious). Jan 7, 2015 at 8:13

6 Answers 6

78

If you are still getting errors with the url, try brew update and then brew install maven. Fixed the problem for me.

1
  • Thanks - this is still occurring years later with a fresh installation of homebrew, but running brew update fixes the issue.
    – Ray M
    Jan 6, 2015 at 23:20
18

There is something strange with this mirror. You can change this with

brew edit maven

and change the url to

http://www.apache.org/dyn/closer.cgi/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz

e.g.

require 'formula'

class Maven < Formula
  homepage 'http://maven.apache.org/'
  #url 'http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.tar.gz'
  url 'http://www.apache.org/dyn/closer.cgi/maven/maven-3/3.0.4/binaries/apache-maven-3.0.4-bin.tar.gz'
  sha1 '0de5dc162bafde3fcb0a6b009cfeea81a042523b'

  def install
    # Remove windows files
    rm_f Dir["bin/*.bat"]

    # Fix the permissions on the global settings file.
    chmod 0644, Dir["conf/settings.xml"]

    prefix.install %w{ NOTICE.txt LICENSE.txt README.txt }
    # Install jars in libexec to avoid conflicts
    libexec.install Dir['*']
    bin.install_symlink Dir["#{libexec}/bin/*"]
  end
end
4
  • 1
    I get the same problem with this new URL. May 17, 2013 at 9:41
  • @fickle, you can manually verify that URL, if it's not accessible manually then it won't work in brew. Most possibly the maven version is different, just update the new version, it will work like magic.
    – May
    Jun 21, 2013 at 4:59
  • 1
    See automated solution below
    – Karan
    Nov 2, 2013 at 23:06
  • I get a similar error : ==> Downloading http://www.apache.org/dyn/closer.cgi/maven/maven-3/3.0.4/binaries/ap Error: Couldn't determine mirror. Try again later.
    – gprasant
    Sep 15, 2014 at 19:43
7

ZenBalance's answer worked for me. I first attempted Emoloney's answer, which caused the following error when I ran brew update:

error: Your local changes to the following files would be overwritten by merge:
Library/Formula/maven.rb
Please, commit your changes or stash them before you can merge.
Aborting Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

To fix it:

cd /usr/local/Library/Formula
git reset --hard

Then:

brew update
brew install maven
1

You need to modify the URL using brew edit like Emoloney said, but most important, don't forget to modify the sha1 code (get it from the same download page of the url). It is important to verify that you downloaded safely the exact file

0

For me, the following commands did the work:

brew update
brew install maven
0

update the mirror list of brew first

brew update

and then, try to install again. For this case

brew install maven

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.