Install Homebrew package and ignore md5 hash

homebrew

I am trying to install some software using homebrew, and when downloading and trying to install one of the dependencies, the package won't install because of an MD5 mismatch.

Is it possible to get homebrew to ignore the MD5 hash of a file and carry on with the installation?

Best Answer

As one comment left on your OP mentioned: I'd be concerned that MD5 sums weren't matching. It could mean the tarball you're downloading is corrupt, in which case doing the above to override the match will actually cause you trouble because you'll be installing broken tools. Or it could be that the tarball you're downloading can't be trusted, that you're being given something that's not legit and contains potentially harmful routines. I'd make sure you're homebrew repository is up to date with:

brew update

If indeed it is up to date you can try:

brew install --force <package>

to force the installation. That option usually just forces a re-installation of an already-installed package of the same version but it may ignore an MD5 error. I poked through the install routine in homebrew but it wasn't apparent this would work.

Worse case: you could just download the tarball for the formula, calculate the MD5 for it by hand and then update the Formula file with the appropriate MD5 value to get past the check. For example, if you were having trouble installing dos2unix you find the formula file in /usr/local/Library/Formula/dos2unix.rb. At the top of the file is the tarball and the MD5 sum for it:

> more dos2unix.rb 
require 'formula'

class Dos2unix < Formula
  url 'http://waterlan.home.xs4all.nl/dos2unix/dos2unix-5.3.1.tar.gz'
  md5 '438c48ebd6891b80b58de14c022ca69e'
  homepage 'http://waterlan.home.xs4all.nl/dos2unix.html'

If the MD5 check is failing, download the tarball:

> wget http://waterlan.home.xs4all.nl/dos2unix/dos2unix-5.3.1.tar.gz
--2012-03-17 18:07:07--  http://waterlan.home.xs4all.nl/dos2unix/dos2unix-5.3.1.tar.gz
Resolving waterlan.home.xs4all.nl... 194.109.6.92, 2001:888:0:18::80
Connecting to waterlan.home.xs4all.nl|194.109.6.92|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 54967 (54K) [application/x-gzip]
Saving to: `dos2unix-5.3.1.tar.gz'

100%[==============================================================================================================>] 54,967      84.8K/s   in 0.6s    

2012-03-17 18:07:09 (84.8 KB/s) - `dos2unix-5.3.1.tar.gz' saved [54967/54967]

Calculate the MD5 checksum for the file yourself:

> md5 dos2unix-5.3.1.tar.gz 
MD5 (dos2unix-5.3.1.tar.gz) = 438c48ebd6891b80b58de14c022ca69e

And then enter the value you computed in to the formula file for the bundle and re-run the install command for the bundle.