MacOS – Problem downloading some urls with cURL on OSX

homebrewmacos

I have problem downloading some applications with homebrew. I could get them when the download urls start with
https://

but curl fails when the urls start with,
ftp:// or http://

For example, I want to install GMT (generic mapping tools) with homebrew on my Mac OS 10.7.4. and I get the error below. I think curl has problem downloading .tar.gz file, but I have no problem downloading the same file with Firefox.

$ brew install homebrew/science/gmt
==> Tapping homebrew/science
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-science'...
remote: Counting objects: 553, done.
remote: Compressing objects: 100% (551/551), done.
remote: Total 553 (delta 2), reused 67 (delta 1), pack-reused 0
Receiving objects: 100% (553/553), 432.61 KiB | 367 KiB/s, done.
Resolving deltas: 100% (2/2), done.
Tapped 546 formulae (572 files, 2.9M)
==> Installing gmt from homebrew/homebrew-science
==> Installing dependencies for homebrew/science/gmt: cmake, libpng, gifl
==> Installing homebrew/science/gmt dependency: cmake
==> Downloading http://www.cmake.org/files/v3.3/cmake-3.3.1.tar.gz

curl: (7) couldn't connect to host

As a workaround, I downloaded the make-3.3.1.tar.gz file with Firefox and copied it to /Library/Caches/Homebrew/ and it worked. So I downloaded the .tar.gz files for each dependency. They all worked until downloading a .zip file proj-datumgrid-1.5.zip which looks like a data file used by the dependency proj.

Maybe I need to rename the .zip file downloaded somehow so that Homebrew recognize it. Or should I need to put it elsewhere
. How does homebrew use these files?

$ brew install homebrew/science/gmt
==> Installing gmt from homebrew/homebrew-science
==> Installing dependencies for homebrew/science/gmt: proj, libgeotiff, geos, readline, sq
==> Installing homebrew/science/gmt dependency: proj
==> Downloading http://download.osgeo.org/proj/proj-4.9.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/proj-4.9.1.tar.gz
==> Downloading http://download.osgeo.org/proj/proj-datumgrid-1.5.zip

curl: (7) couldn't connect to host
Error: Failed to download resource "proj--datumgrid"

Best Answer

Have you tried running

brew update

and

brew updgrade

before

brew install homebrew/science/gmt

Usually many problems with formulas may be solved by simply updating & upgrading homebrew and its formulas!