Closed motohedgehog closed 5 months ago
i've got a feeling you're redirection isn't actually going to stdin in time. the < Brewfile
won't be evaluated until after the command which means stdin would be empty and the behaviour here makes sense.
what does behaviour cat Brewfile | brew bundle --cleanup --file=-
give you?
@jacobbednarz my shell knowledge may be a bit rusty, but I don't think cat file | command
vs command < file
should make any difference here (a.k.a. "useless use of cat
"). I tried you suggestion though, and the behaviour remains the same.
That said, I've got very similar suspicions: an empty Brewfile
indeed makes brew bundle [install] --cleanup
try and remove any installed packages, so I have a hunch that it may be working in two passes (install, then cleanup) and by the time it reaches the cleanup stage the stdin is already consumed thus making it purge everything. In any case, I don' think it is the expected/desired behaviour.
It's been a while since I did any Ruby so I haven't looked at the implementation TBH.
by the time it reaches the cleanup stage the stdin is already consumed thus making it purge everything
Exactly this. Fixed in #1379. Thanks for the great report @motohedgehog!
nice find!
Overview
I did my best to find any similar bug reports, but couldn't, so here goes.
I've run into a weird
brew bundle
behaviour while working on declarative package management in my personal dotfiles repo (I use chezmoi).How To Reproduce
I could reproduce the problem on a pristine macOS 14.5 running under UTM and a clean Homebrew installation.
Suppose I install one formula and one cask:
I then run
brew bundle dump
and get myBrewfile
:At this point, I expect
brew bundle [install] --cleanup
to be a no-op. At a first glance, it is:However, things change if I pass the very same Brewfile via stdin:
Homebrew says
Bundle complete
, but then immediately proceeds to remove both the formula and the cask.Running
brew bundle
again exhibits even more bizarre behaviour as it install the formula and the cask again, and then removes the cask only:Debug Information
I hope I am just missing something obvious, but so far I've been puzzled, so any help would be appreciated!