You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There list brew list --full-name, but it's mutually exclusive with --versions, sadly.
Possibly the most robust way is to use brew info --json --installed for BrewPackages fact.
This contains both full_name attribute and versions (and perhpas better to use json than plaintext parsing anyway).
Switching to full_name might break things though, e.g. if someone had the appropriate brew tap already, they could simply use brew.packages skhd. So BrewPackages fact would need to somehow handle both full and short name which could be awkward... Or maybe it's fine to break backwards compatibility for third party taps, and always switch to using full names (it wouldn't affect "default" tap, since for them name and full_name are the same). But don't really have an opinion here, not a heavy brew user, so don't know what was the intent there!
Possible workaround/improvements
I guess I could explicitly specify brew.tap koekeishiya/formulae, and then use brew.packages skhd, so both operations are idempotent and correctly detect no changes.
Maybe it's worth documenting this as a more consistent approach, and/or warn if user executes brew.packages package/name/with/slashes, suggesting to setup tap and use the short name to avoid inconsistencies.
Meta
Using latest version of pyinfra (3.2)
The text was updated successfully, but these errors were encountered:
To Reproduce
Consider this command -- if you run it for the first time, it succeeds without issues:
pyinfra @local brew.packages koekeishiya/formulae/skhd
Now if you run it again:
As you can see, it suggests that something is due to change, even though the package is already installed!
However, I'd expect this to report no changes! E.g. similar to running
brew.packages git
twice.Why this happens
I looked at the code --
facts.brew.BrewPackages
is usingbrew list --versions
command to get information about packagespyinfra/pyinfra/facts/brew.py
Lines 70 to 71 in 935ce07
But this lists packages without full name (which is
koekeishiya/formulae/skhd
orkoekeishiya/formulae/yabai
in this case)There list
brew list --full-name
, but it's mutually exclusive with--versions
, sadly.Possibly the most robust way is to use
brew info --json --installed
for BrewPackages fact.This contains both full_name attribute and versions (and perhpas better to use json than plaintext parsing anyway).
Switching to
full_name
might break things though, e.g. if someone had the appropriate brew tap already, they could simply usebrew.packages skhd
. So BrewPackages fact would need to somehow handle both full and short name which could be awkward... Or maybe it's fine to break backwards compatibility for third party taps, and always switch to using full names (it wouldn't affect "default" tap, since for them name and full_name are the same). But don't really have an opinion here, not a heavy brew user, so don't know what was the intent there!Possible workaround/improvements
I guess I could explicitly specify
brew.tap koekeishiya/formulae
, and then usebrew.packages skhd
, so both operations are idempotent and correctly detect no changes.Maybe it's worth documenting this as a more consistent approach, and/or warn if user executes
brew.packages package/name/with/slashes
, suggesting to setup tap and use the short name to avoid inconsistencies.Meta
Using latest version of pyinfra (3.2)
The text was updated successfully, but these errors were encountered: