Homebrew / homebrew-bundle

📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.
MIT License
5.31k stars 285 forks source link

Manage old terraform version with homebrew-bundle #400

Closed johnnyplaydrums closed 5 years ago

johnnyplaydrums commented 5 years ago

Hey! We love managing brew dependencies with homebrew-bundle but have run into a snag trying to support older versions of terraform. We need to run terraform 0.11.7, and with the homebrew cli we can do:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0a5f283f5fa18b4bd2dc0e111ca83257af962c9d/Formula/terraform.rb

and I'll be set with terraform 0.11.7. But I haven't been able to figure out how to achieve that via a Brewfile. I may have missed the obvious solution but, any suggestions?

Thank you!

jacobbednarz commented 5 years ago

Just digging through the source at the moment however I think the only way you could do this is by creating your own tap and directly referencing that in your Brewfile.

tap "my-org/terraform" # optionally include the repo path if needed
brew "my-org/terraform/terraform"

See the full documentation on Taps if this might be of interest.

johnnyplaydrums commented 5 years ago

@jacobbednarz thanks for the quick response! That's not a bad solution, I think we can go with that solution for now. I don't know if there is a homebrew-bundle native way to handle this scenario but if not, creating our own tap will work. Would be curious if anyone out there has tried to solve this problem before.

johnnyplaydrums commented 5 years ago

@jacobbednarz trying your suggestion, homebrew is telling me to use switch. I don't think homebrew-bundle has support for a switch statement does it?

$ brew tap "johnplaydrums/terraform"
$ brew install "johnplaydrums/terraform/terraform"
Warning: johnplaydrums/terraform/terraform 0.11.7 is already installed
The currently linked version is 0.11.10
You can use `brew switch terraform 0.11.7` to link this version.

We want to enforce the 0.11.7 installment (or any other version in the future). Of course we could have our engineers run brew switch terraform 0.11.7 but we were hoping to be able to resolve all dependencies needs with just brew bundle. Thanks again!

colindean commented 5 years ago

I think the best solution here is to use tfenv.

https://github.com/Zordrak/tfenv

johnnyplaydrums commented 5 years ago

Thanks @colindean! If using tfenv is the best solution to this use case I'm happy to close this issue

colindean commented 5 years ago

Yeah, tfenv is def. the best way to control what version of tf you're using.

johnnyplaydrums commented 5 years ago

@colindean cool thank you. Also I guess I meant the question a little more broadly than just terraform. Like should homebrew-bundle support more features to manage specific homebrew deps. (e.g. switch support maybe?). happy to contrib / pr if there is a need

colindean commented 5 years ago

IIRC, one of the philosophies of Homebrew is that only the latest version of a formula is supported. I'm not sure we'd want to support installing old formula in this way.

@MikeMcQuaid can chime in…

MikeMcQuaid commented 5 years ago

We support multiple versions but not installing random versions from a Git commits which are immutable. See https://docs.brew.sh/Versions which is the supported path.

johnnyplaydrums commented 5 years ago

Sounds good, thank you both!