12

I'm trying to use Homebrew to install wget, but something is happening where the download is always corrupt. This happens for all packages, not just wget. I can download the tar.gz fine through a browser. Can I use Homebrew to install a locally downloaded archive? Something such as:

brew install wget-1.14.tar.gz 
  • 1
    Seems very odd. I don't know of you can do that but it sounds like something more serious is happening. Have you tried running brew doctor? – boyfarrell Mar 6 '13 at 2:45
  • If you have the exact archive that Homebrew's expecting, you can put it in ~/Library/Caches/Homebrew and then try brew install. But this is mysterious. How about posting the output of brew install when you try it the normal way? – echristopherson Mar 6 '13 at 2:48
  • @echristopherson Your method worked. If you post it as an answer, I'll accept it. – MD6380 Mar 7 '13 at 17:34
  • I know why it doesn't work. Brew doctor doesn't show any issues. It looks like the HTTP proxy being used isn't allowing the download. – MD6380 Mar 7 '13 at 17:35
  • Just to note, this is useful when there are multiple mirrors and the one in the recipe doesn't work. You can set a different SourceForge mirror via an environment variable, but for others the accepted solution is very useful. – Dan Jul 31 '13 at 19:58
21

If Homebrew already has a formula for it (in /usr/local/Library/Formula), and you have the exact archive that the formula expects (i.e. same file name and same contents, as determined by SHA1 or whatever hash type the formula uses), you can put the archive in ~/Library/Caches/Homebrew and then try brew install formula_name (substituting the correct name for formula_name, of course).

  • 2
    Homebrew folder does not exist, but it works after I mkdir one. – eccstartup Oct 17 '13 at 14:57
  • brew install didn't work for me, but brew install <package> did. Thanks! – Zayne S Halsall May 16 '16 at 11:59
  • Oh, I had left that implicit. I'm fixing that in my answer. – echristopherson May 16 '16 at 19:12
3
$ brew install -f wget-1.14.tar.gz
  • 1
    Different package but same requirement, -f doesn't appear to work: zaynehalsall@mbp:~$ brew install -f Library/Caches/Homebrew/pwgen-2.07.tar.gz Error: No available formula with the name "Library/Caches/Homebrew/pwgen-2.07.tar.gz" ==> Searching for similarly named formulae... Error: No similarly named formulae found. ==> Searching taps... Error: No formulae found in taps. zaynehalsall@mbp:~$ – Zayne S Halsall May 16 '16 at 11:57
  • 1
    same error happens – Ben Sep 6 '16 at 7:51
3

Five years and change late to the party, but:

The trick is to move the archive into brew's cache. Said cache can be a pain to find by hand; fortunately, you don't have to. Just ask brew itself with brew --cache.

This lets you do the following in bash:

mv wget-1.14.tar.gz $(brew --cache)

alternately, in fish:

mv wget-1.14.tar.gz (brew --cache)

After which running brew install wget should result in brew announcing that it's downloading the archive, followed immediately by its realization that the archive is "Already downloaded", and everything proceeding smoothly from there.

0

It is possible to pre-download a file for a formula but you will need correct cache file name which can be generated using brew --cache -s <formula>.

For example, for Erlang formula, brew --cache -s erlang will print the correct name of the cached download. This means instead of manually renaming a formula, you can run:

wget source-version.tar.gz
mv source-version.tar.gz $(brew --cache -s <formula>)
  • This works for the current version of a formual — but if I want to reinstall node 11 rather than the current node 12, brew --cache -s node still gives me the path for node 12. Do you know how I can force Homebrew to install the older version? – John Y Jun 17 at 16:14
0

According to this:

Not really without modifying the formula file.

if your local archive is pre-build file, aka 'bottle' in Brew. Here is what I dig out:

The brew bottle is MacOS version-related.

Take pkg-config for example.

here on https://bintray.com/homebrew/bottles/pkg-config#files/, it lists different files for different MacOS version.

After downloading the correct file, you need to move it to correct path which can be generated by brew --cache --force-bottle pkg-config

for 10.14: it's like:

/Users/username/Library/Caches/Homebrew/downloads/dd6c78ec64b7c09961ccdb1bf873b5852fd93783cf25ae9b9399c5896a420462--pkg-config-0.29.2.mojave.bottle.tar.gz

for 10.13: it's like:

/Users/username/Library/Caches/Homebrew/downloads/8b865a8ad8179d4a45289cab9267cc5e3a6153d06432d90cf1745caf5d92a64d--pkg-config-0.29.2.high_sierra.bottle.tar.gz

after that, brew can find the cached local file when you run brew install pkg-config. otherwise, it will still download from a URL.


just move file to $(brew --cache) won't work anymore, at least for today's brew( 2.19 version in my case).

  • if the local file is source code, not a bottle. Moving it to $(brew --cache -s formula) will work if you force to install it with option --build-from-source . – gebitang Aug 15 at 12:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .