How are `bottle` and `postinstall` related? Is it safe to run `bottle` after `postinstall`?


If I brew install --build-bottle <pkg>, it says eventually:

==> Not running post_install as we're building a bottle

Which suggests that using brew bottle and brew postinstall together is maybe problematic somehow. However, says nothing whatsoever about this little gimmick, or the relation of these two commands in general.

So, here are the questions:

  1. Why is that done? The package is being installed into the local cellar anyway rather than just packaged, other packages will still see it and may try to use. What does that achieve?
  2. What are the implications before running postinstall, or running bottle after postinstall or vice versa?

I’m primarily interested in official guarantees / documented behavior 'cuz I’m writing scripts and must know what I can rely on.

(Sean Molenaar) #2

It’s not explicit about it (pull requests welcome) but it does mention that --build-bottle is to be used with eventual bottles. These would need an install without postinstall applied as they’re only precompiled source to be shipped (and not configured by postinstall yet).
The implications are mostly that it might very well break your bottle to run a postinstall, especially since it’d be run on the target system as well.


So, the supported procedure is like the following?

brew install --build-bottle <pkg>
brew bottle <pkg>
brew postinstall <pkg>

# Now I can eat the cake and have it use the package locally and have a bottle, too

(Mike McQuaid) #4

The supported procedure is technically:

brew install --build-bottle <pkg>
brew bottle <pkg>
brew uninstall <pkg>
brew install <bottle> 

and the final brew install will run the postinstall.


Thanks for quick replies and the info!
Here’s a PR to document this:

Are you sure this is really the only supported way? Because

==> Not running post_install as we're building a bottle
You can run it manually using `brew postinstall <pkg>`

clearly suggests that following this advice – i.e. running postinstall afterwards – will give you a working installation (otherwise, there’s no point in suggesting it).

(Mike McQuaid) #6

I’m using “supported” in a particular way here to indicate “the way we use it and will help you fix any issues that come up when using it this way”. This does not mean that it’s known to break if you e.g. run brew postinstall manually but just that we don’t use it that way.

In general if you are building a bottle you intended to be doing so for distribution of that bottle to other machines which will install the package from the bottle. You are free to use this functionality any way you like including running postinstall never, once or more than once but we may not fix breakages that result if reported.

Make sense?


Yes, pretty much.

But in this light, the “You can run it manually” message is useless at least and harmful at most 'cuz if I heed its advice, I’ll be left with an unsupported setup – and not even know that.

Thanks for the PR but this isn’t a question that comes up often so there’s no need to be explicit when there’s no known issues. I’ll comment again on the Discourse thread.

Well, if you think it won’t do harm being left as it is, fine by me. You are the boss.