Homebrew / homebrew-bundle

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

Feature Request: Include File Directive #541

Closed brennydoogles closed 5 years ago

brennydoogles commented 5 years ago

Hello! As someone who changes computers regularly (often as a result of changing jobs as a software engineer) I would love to be able to keep a master list of applications that I use, and then pick and choose which get installed on a given machine based upon what the machine will be used for.

For example, my current Brewfile contains applications that fall into the following categories: Java Development, Python Development, Go Development, Javascript Development, General System Utilities, Retro Video Games, Music Production, and Video Production. At home, I would likely have all of these apps installed, but at work I would want to exclude video games, music, and video production. Additionally, depending on the specific job I accept at a given time I will probably be developing in a subset of the programming languages I currently have in my Brewfile.

Currently in order to manage such a setup I can do so by having a massive Brewfile, and then going through and deleting 50-100 lines of it before installing on a new machine, but this is time intensive and I often end up installing things I don't need because I miss them while deleting.

Ideally, I would love to be able to create a Brewfile for each of these categories, and then have a master Brewfile which then includes the category Brewfiles. This way when installing on a new machine, I could simply copy the folder containing my Brewfiles, edit the master Brewfile to include only the category Brewfiles I need (this will be much easier as the master Brewfile will now be 5-10 lines long), and the install as normal.

Proposed Syntax: include "Brewfile-java" include "Brewfile-python" tap "something" brew "thething"

colindean commented 5 years ago

See https://github.com/Homebrew/homebrew-bundle/issues/521 and https://github.com/Homebrew/homebrew-bundle/issues/434 for how others have achieved this.

brennydoogles commented 5 years ago

See #521 and #434 for how others have achieved this.

@colindean in #434 I see that you've recommended 'require', but in #521 we have the following comment that states that 'require' doesn't work as expected: https://github.com/Homebrew/homebrew-bundle/issues/521#issuecomment-509023100

There is a massively hacky workaround in the next comment down, but it's not particularly user friendly (and of course the only documentation is the single comment). Given that this is the third (that I'm aware of) request for this feature in less than a year, I would argue that the proposal is worth considering.

I'm not a ruby developer, but I'll poke through the source code and see if I can put together a more technical proposal on how to add this capability in a way that is more in line with how the rest of the tool works.

MikeMcQuaid commented 5 years ago

Given that this is the third (that I'm aware of) request for this feature in less than a year, I would argue that the proposal is worth considering.

We'll review a PR that fixes require or require_relative to work as expected. include is already a Ruby keyword so cannot be used.

Currently in order to manage such a setup I can do so by having a massive Brewfile, and then going through and deleting 50-100 lines of it before installing on a new machine, but this is time intensive and I often end up installing things I don't need because I miss them while deleting.

Alternatively: having one Brewfile for each language you're working in. brew bundle is designed to be used by having it in your project root; think of it like a Gemfile rather than a "list of things I need on my machine".

edit the master Brewfile to include only the category Brewfiles I need (this will be much easier as the master Brewfile will now be 5-10 lines long), and the install as normal.

This still requires editing the Brewfile manually for each new machine you use which seems pretty suboptimal. This is why we recommend making your configuration per-project in this case.

MikeMcQuaid commented 5 years ago

Given that this is the third (that I'm aware of) request for this feature in less than a year, I would argue that the proposal is worth considering.

Also just to be super explicit: in all these cases there's a certain amount of "this isn't how brew bundle is intended to be used". I'd rather make the intended use-cases/solutions clearer and better documented rather than work to actively support an undesirable (for us) one.

ianwremmel commented 5 years ago

I use bundle files as part of my dotfiles setup and I've found i need separate packages on my work and personal computers.

I wasn't able to get any of the recommended hacks in this repo to work as expected, but I managed to make a dynamic setup with ERB:

export BREWFILE="$(mktemp)"
erb Brewfile.erb > "$BREWFILE"
brew bundle --file="$BREWFILE"