hashicorp / homebrew-tap

Homebrew Tap of HashiCorp products and tools
Mozilla Public License 2.0
127 stars 54 forks source link

hashicorp/tap/terraform formula not Idempotent when used with Brewfile #53

Open adyang opened 3 years ago

adyang commented 3 years ago

Hi Team,

Given that hashicorp/tap/terraform is already installed, creating a Brewfile at /tmp/Brewfile with the following contents:

brew "hashicorp/tap/terraform"

and running brew bundle --file=/tmp/Brewfile --verbose results in the following output:

Unlinking terraform formula.
It is currently installed and conflicts with terraform.
Unlinking /usr/local/Cellar/terraform/0.13.3... 1 symlinks removed
Skipping install of terraform formula. It is already up-to-date.
Using hashicorp/tap/terraform

Running terraform would then result in: terraform: command not found.

Expected result would be that the symlink is not removed and that running terraform would print usage.

Thanks for the attention.

radeksimko commented 3 years ago

Hi @adyang It looks like this may be a result of a slightly confusing conflict between the community-maintained terraform formula and the one we maintain here. I admit I haven't tried bundling with taps myself though, so I may be wrong.

Have you tried brew uninstall terraform before bundling it?

adyang commented 3 years ago

Hi @radeksimko

I have tried brew uninstall terraform before bundling but it ended up uninstalling hashicorp/tap/terraform (the homebrew core terraform was not installed in the 1st place).

I tried bundling again but it seems like repeated runs would alternate between removing the symlink and creating the symlink.

dexterous commented 3 years ago

Hi guys, This is a quirk of Homebrew; Formulas/Casks are not really namespaced by their Tap, the Tap name is only relevant during Formula/Cask lookup.

Refer Homebrew Taps Docs.

This is (most likely) further aggravated by how the install sub-command reports Formula/Cask names fully qualified even if the lookup in the Cellar is performed with just the unqualified name.

There should be some workaround to this that doesn't require us to rename the Formulas altogether (as suggested in the Homebrew Docs). I'll spend some time spelunking through the brew code when I get a spare hour or so.