Homebrew: SHA1 Mismatch Even After Update
Solution 1:
If you're certain the downloaded tarball for sshfs
is good can try to force Homebrew to install it with:
brew install -f sshfs
More than likely though, if it still complains, is you've got a corrupt tarball download. You can remove /usr/local/Cellar/sshfs/2.4.0/sshfs_2_4_0
, which is the cached tarball that Homebrew downloaded, and have Homebrew try downloading the package anew.
If it still complains about the hash value mismatch, you can edit the recipe and update the MD5 checksum for the file in the recipe and then install. The file to edit is /usr/local/Library/Formula/sshfs.rb
. Looking at:
/Users/ian/code/tmp/brew [ian@Ian-Chesals-MacBook-Pro] [13:13]
> cat /usr/local/Library/Formula/sshfs.rb
require 'formula'
class Sshfs < Formula
homepage 'http://fuse.sourceforge.net/sshfs.html'
url 'https://github.com/fuse4x/sshfs/tarball/sshfs_2_4_0'
md5 'c9ea547b9684ec4d85437393a2731322'
version '2.4.0'
depends_on :automake
depends_on :libtool
depends_on 'pkg-config' => :build
depends_on 'fuse4x'
depends_on 'glib'
def install
system "autoreconf", "--force", "--install"
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
def caveats; <<-EOS.undent
Make sure to follow the directions given by `brew info fuse4x-kext`
before trying to use a FUSE-based filesystem.
EOS
end
end
You can see that you need to download https://github.com/fuse4x/sshfs/tarball/sshfs_2_4_0 and recalculate the MD5 checksum for the file and then update the recipe. So:
/Users/ian/code/tmp/brew [ian@Ian-Cs-MacBook-Pro] [13:13]
> wget https://github.com/fuse4x/sshfs/tarball/sshfs_2_4_0
--2012-07-23 13:13:53-- https://github.com/fuse4x/sshfs/tarball/sshfs_2_4_0
Resolving github.com... 207.97.227.239
Connecting to github.com|207.97.227.239|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://nodeload.github.com/fuse4x/sshfs/tarball/sshfs_2_4_0 [following]
--2012-07-23 13:13:53-- https://nodeload.github.com/fuse4x/sshfs/tarball/sshfs_2_4_0
Resolving nodeload.github.com... 207.97.227.252
Connecting to nodeload.github.com|207.97.227.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 52812 (52K) [application/octet-stream]
Saving to: `sshfs_2_4_0'
100%[===========================================================================================>] 52,812 288K/s in 0.2s
2012-07-23 13:13:54 (288 KB/s) - `sshfs_2_4_0' saved [52812/52812]
/Users/ian/code/tmp/brew [ian@Ian-Cs-MacBook-Pro] [13:13]
> md5 sshfs_2_4_0
MD5 (sshfs_2_4_0) = c9ea547b9684ec4d85437393a2731322
In my case the computed value for the download matches the value in the recipe. If it's different for your case it's likely your download is corrupt. You can go ahead and update the recipe if you think your download is not corrupt.
Note: I did a brew update
before running the above so I can attest to the fact that I do have the latest recipe for sshfs
and that the MD5 checksum for the tarball in the recipe is correct and matches what gets downloaded from github.
Caveat Utilitor if you do this.
Solution 2:
OK, so it turns out the problem was not with Homebrew, but with cURL, which was only downloading 2 KB of whatever file I threw at it and then failing. I was able to fix this by installing the latest version of cURL.
Steps taken to resolve:
- Opened http://curl.haxx.se/download/curl-7.27.0.tar.gz in a web browser, saved to
/Library/Caches/Homebrew/
. - Ran
brew install curl
. - Any time I got a hash mismatch when downloading a dependency, I did steps 1 and 2 again, replacing the cURL package location with the one listed in the console output for the respective dependency.
- By default, OS X uses
/usr/bin/curl
, whereas the Homebrew version apparently lived in/usr/local/Cellar/curl/7.27.0/bin/curl
. Which actually should have been symlinked as/usr/local/bin/curl
, but wasn’t for some reason—brew link curl
fixed that though (may have had to repeat for dependencies). - However, Homebrew apparently has the philosophy that it’s desirable to always use Apple’s system-default binaries if they’re available. Wasn’t in my case, so I followed this advice and added
export PATH=/usr/local/bin:$PATH
to my bash profile, to do the reverse, and always use Homebrew binaries first, despite whatever bleeding edge repercussions that may have. -
brew update
. -
brew install sshfs
—success!
Many thanks to Ian C. for taking the time to chat with me and point me in the right direction.
Solution 3:
Had a similar problem when trying to install sdl_image (brew install sdl_image)
brew install sdl_image
==> Downloading http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.1
######################################################################## 100.0%
Error: SHA1 mismatch
Expected: 5e3e393d4e366638048bbb10d6a269ea3f4e4cf2
Actual: 96553a2470b51f5cca98d9c390c56bacd12f8ed4
However, got it working after realizing I was behind a server that zeros/breaks files if they exceed a certain size hence being corrupted. Solved it by moving to another network and trying to reinstall. Though I got the same error I knew the file was complete because the expected sha given the previous errors was now given in the actual sha.
Then to successfully complete as I came across trying to solve the problem was to brew edit sdl_image
and copy the actual sha to the sha in the file.
Solution 4:
I had a similar problem with zlib-1.2.8. The root cause though was that I had a .curlrc
file that specified --compressed
, and that option causes curl to decompress the file before writing it out.
Removing the option fixed the problem for me, but I don't know if there's a better fix available.