Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.
  • Mac OS X 10.7.4 (Lion)
  • Homebrew 0.9.2

Fresh install of Homebrew. No program will install on its own—the expected hash signature never matches the actual one, for whatever reason.

The only answer I have found online is to do brew update beforehand. I did this, and deleted the previously-downloaded package, but it doesn’t seem to have any effect:

 $ brew update
 Already up-to-date.
 $ brew install sshfs
 ==> Installing sshfs dependency: autoconf
 ==> Downloading http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
 ######################################################################## 100.0%
 Error: SHA1 mismatch
 Expected: 562471cbcb0dd0fa42a76665acf0dbb68479b78a
 Actual: 304f244353d8b7694914ff42fa87f31608728aed
 Archive: /Library/Caches/Homebrew/autoconf-2.69.tar.gz
 (To retry an incomplete download, remove the file above.)

What’s going on?

Edit: If I download a package manually, and put it into /Library/Caches/Homebrew/ with the same filename that Homebrew expects, and then try to install, it works fine. But if I let Homebrew try to fetch the file itself, the download ends prematurely after only a few kilobytes which corrupts the file and causes the hashes not to match.

share|improve this question
    
Related: apple.stackexchange.com/questions/36862/… –  Ian C. Jul 23 '12 at 17:09
    
My downloads are corrupting so ignoring the hashes would be asking for trouble. –  Hugh Guiney Aug 8 '12 at 18:37
add comment

3 Answers

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.

share|improve this answer
    
Thanks for the detailed instructions, but unfortunately this doesn’t help. The mismatch happens for every single program I try to download—it seems they are all corrupted on arrival. –  Hugh Guiney Aug 8 '12 at 18:35
    
That's likely a bigger issue then. Are you behind a corporate firewall that might be zeroing out files that end in specific extensions? –  Ian C. Aug 8 '12 at 18:55
    
Nope, I’m not. As I say in the edited OP, I can download tarballs outside of Homebrew, and they won’t corrupt. –  Hugh Guiney Aug 8 '12 at 19:05
    
How are you downloading the file? IIRC homebrew uses curl. If you curl the file, does it download okay? Try setting HOMEBREW_DEBUG=1 and HOMEBREW_CURL_VERBOSE=1 in your environment before calling homebrew to install something and see if says more about what it's doing. –  Ian C. Aug 8 '12 at 19:09
1  
let us continue this discussion in chat –  Ian C. Aug 8 '12 at 19:55
show 2 more comments
up vote 1 down vote accepted

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:

  1. Opened http://curl.haxx.se/download/curl-7.27.0.tar.gz in a web browser, saved to /Library/Caches/Homebrew/.
  2. Ran brew install curl.
  3. 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.
  4. 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).
  5. 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.
  6. brew update.
  7. brew install sshfs—success!

Many thanks to Ian C. for taking the time to chat with me and point me in the right direction.

share|improve this answer
    
Nice! Glad to hear you got it working! –  Ian C. Aug 10 '12 at 1:00
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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