7

Is there a way to install a package and include all --with* options instead of typing all of them individually at the CLI?

To avoid:

brew install ffmpeg --with-chromaprint --with-fdk-aac ...
7

Disclaimer: I'm not so familiar with grep. Smarter solutions are welcome.


You can list all options with this command.

brew options target_formula

And you can get all --with-* options with this.

brew options target_formula | grep 'with-'

So you can install a formula with all --with-* options by this.

brew install target_formula `brew options target_formula | grep 'with-'`

Note that some formula, especially in unofficial tap, can have old options not prefixed with --with- or --without.



EDIT: If you want to exclude specific option, for example --with-zimg, you can do that with this.
(grep -v 'with-zimg' is fine, but grep -v 'zimg' is shorter)

brew install target_formula `brew options target_formula | grep 'with-' | grep -v 'zimg'`
  • I initially tried brew install ffmpeg "$(brew options ffmpeg | grep 'with-')", which threw a warning: Warning: ffmpeg: this formula has no --with-chromaprint, followed by all of the remaining with- options, each on a new line. The last line read: --with-zimg option so it will be ignored. ffmpeg was then installed without any of the with- options. – waxwing Jan 10 '17 at 6:15
  • I then tried to reinstall using backticks instead of "$()", and the installation process did not proceed past throwing the following warning: zimg: macOS El Capitan or newer is required. Error: An unsatisfied requirement failed this build. I then tried once more using "$()" and the same result as the first installation attempt occurred. – waxwing Jan 10 '17 at 6:21
  • Regarding the first comment, you shouldn't use " ". This will squash all option into one option --with-chromaprint --with-fdk-aac ..., which brew can't recognize properly. – equal-l2 Jan 10 '17 at 8:44
  • Regarding the second comment, you have no way but installing ffmpeg without --with-zimg. See the edited answer. – equal-l2 Jan 10 '17 at 8:54
2

There is no wildcard-expansion mechanism for arguments in Homebrew, so the possibility to select all options, would depend on the implementation of each formula.

Looking at the ffmpeg formula code, each option is handled individually, so it is not possible using the current version.

You would have to modify the formula removing the conditionals in lines like:

args << "--enable-chromaprint" if build.with? "chromaprint"

Or add a global switch for all arguments; or change the logic to install all by default and make the switches for disabling options.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .