How to use a local copy of a cask during first-time installation?

So I have a cask (custom app i developed for personal use). It’s currently hosted in the cloud but I’ve been trying to find a way for homebrew to use the local copy.

I tried this:

cp -a "/Users/myuser/Download/my-cask-1.1.1.zip" "(brew --cache)/Cask/"
$ brew cask install my-cask

But homebrew still fetches the cloud version of the zip file. Is there a way to prevent it?

Thank you!

You could figure out the place where the files are cached before install and put the file there, but that’s not meant to happen so there’s a reasonable chance it breaks.

1 Like

Perhaps you could change the url in your my-cask.rb file to point to file:///path-to-your-file?

1 Like

Not possible I think. As a sample, I have this cask inside $(brew --cache)/Cask

mycask–19.1.4.0.354.1.zip ⇒ …/downloads/e050397f4fcc363bfa50341c1d2df1cd8009ed7a0f5a6e701c5b7c0ddc325b91–mycask-19.1.4.0.354.1.zip

the “checksum” (the random string) before “mycask” in the filename is not the same as sha256 value that’s in my .rb file

That’s because it’s the SHA256 hash of the download URL, not the actual tarball. For example, with the kitty cask at version 0.18.0, the cask download URL resolves to https://github.com/kovidgoyal/kitty/releases/download/v0.18.0/kitty-0.18.0.dmg, so:

$ echo -n "https://github.com/kovidgoyal/kitty/releases/download/v0.18.0/kitty-0.18.0.dmg" | sha256sum
9eafa9c3ba56e44bffbf952be39577865d83df82ebfe116b8d2e086901cde894  -

$ cd "$(brew --cache)/downloads"

$ ls *kitty*
9eafa9c3ba56e44bffbf952be39577865d83df82ebfe116b8d2e086901cde894--kitty-0.18.0.dmg

$ sha256sum *kitty*
cc217a5386390bef0ae74390a0ce3f2e452983e408571974eb1c984938747dde  9eafa9c3ba56e44bffbf952be39577865d83df82ebfe116b8d2e086901cde894--kitty-0.18.0.dmg
1 Like