I´m wondering whether there is a possibility to install local .dmg
files previously downloaded. I figured out that homebrew
may use archive file (gzip, bz2, tar, etc.)
when putting them into the right path aka /Library/Caches/Homebrew
and rerun brew install
. However, dont know how to install .dmg
files.
2 Answers
I think there are a couple of issues here. Homebrew is a package manager for command line utilities. Homebrew packages are not in .dmg
files.
There is a a related project called homebrew-cask (HBC) that functions as a package manager for GUI apps, the likes of which may indeed be distributed via .dmg
file.
Presuming that you are trying to use cask to install a GUI app distributed in a dmg file, you must understand that the point of a package manager like homebrew-cask (HBC) is that you create or are provided with a script that informs the package manager how to install and manage the software. All DMGs are not innately compatible with HBC.
You can learn about how this works from the guide on contributing to HBC: https://github.com/caskroom/homebrew-cask/blob/master/CONTRIBUTING.md
The short version is that in order to manage a package with HBC, you need to write a "cask", which is a ruby file that gives the package manager a concept of what the package is.
That said, presume that you are trying to install an existing cask, but use a local .dmg file to avoid having to redownload it? I believe Cask will maintain its own download cache, and so theoretically, if your dmg file matches the sha256 hash contained in the cask and you place that dmg in the cache location, cask should be able to install from it without redownloading.
That's as far as I can go right now, so hopefully this helps.
The .dmg
you're trying to install has to already exist as a Cask.
Example:
❯ brew info --cask wireshark
wireshark: 3.6.7 (auto_updates)
https://www.wireshark.org/
Not installed
From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/wireshark.rb
==> Name
Wireshark
==> Description
Network protocol analyzer
==> Artifacts
Add Wireshark to the system path.pkg (Pkg)
Install ChmodBPF.pkg (Pkg)
Wireshark.app (App)
Start the download of the .dmg
you want to install then cancel it
❯ brew install --cask wireshark
==> Downloading https://2.na.dl.wireshark.org/osx/Wireshark%203.6.7%20Arm%2064.dmg
######################## 33.9%
^C
This will create its entry inside ~/Library/Caches/Homebrew/downloads
.
❯ ls ~/Library/Caches/Homebrew/downloads | grep .dmg
86d421998d8b5509f7d8e9631702c2ade285c1dc9b508c39deccb5d19a63c609--Wireshark 3.6.7 Arm 64.dmg.incomplete
Then, copy your .dmg
over that one. Make sure it has the same hash beforehand.
❯ cp ~/Downloads/Wireshark\ 3.6.7\ Arm\ 64.dmg ~/Library/Caches/Homebrew/downloads/86d421998d8b5509f7d8e9631702c2ade285c1dc9b508c39deccb5d19a63c609--Wireshark\ 3.6.7\ Arm\ 64.dmg.incomplete
Finally, resume the installation and it'll be completed in a flash!
❯ brew install --cask wireshark
==> Downloading https://2.na.dl.wireshark.org/osx/Wireshark%203.6.7%20Arm%2064.dmg
==> Installing Cask wireshark
-
If the hash needs to be the same anyway, why not just install via Homebrew?– nohillside ♦Commented Jul 28, 2022 at 20:53
-
Downloads are excruciatingly slow with Homebrew. Downloading apps separately with a proper download manager allow you to use them faster but still have them registered with Homebrew. This wouldn't be a problem if Homebrew allowed using a different download manager or supported parallel downloads or supported multiple connections, but alas, it doesn't and its maintainers are not interested in these features. Commented Jul 28, 2022 at 21:35
cask
which is related to homebrew.