Libpq conflict_with instead of key_only

(Juan Ignacio Donoso) #1


I was wondering why the libpq formula is key-only… It says that it conflicts with postgresql.

The libpq formula installs some executables, like pg_loader, createdb, dropdb, psql all nice command line tools for anyone using portgres.

The postgres formula also installs those executables.

We’ve been using postgres with docker, so we don’t need the whole postgres server and libpq is perfect for that. We can compile pg gem and use the cli tools.

Can we just define conflict_with instead of keg_only?

conflicts_with "postgresql", :because => "Installs same cli tools"

(Sean Molenaar) #2

That seems like a reasonable explanation, could you make a pull request for this?


(Mike McQuaid) #3

We prefer keg_only over conflicts_with because the prior allows both tools to be installed at once.


(Juan Ignacio Donoso) #4

Do I hold my horses with that PR?

Why would like to have both installed?? What I understand is that with libpq you have cli tools and headers to compile gems with native extensions and c clients. With postgresql you have the same plus the server itself.


(Mike McQuaid) #5


Check out brew uses libpq and brew uses postgresql. If you want to have any of those installed at the same time: you need this not to be conflicts_with.


(Juan Ignacio Donoso) #6

I understand, probably is a matter of choice. I only need cli tools and c headers to compile gems… I can choose not to install postgresql.

All this comes from the situation.

There is a tap with a formulae that depends_on postgresql but I would like to propose a change to depends_on libpq, as it doesn’t need the server itself, only the cli binaries. Is there any way in the formulae to declare that the dependency should force link a keg_only formalae? Probably not rigth?

Another alternative would be to have a mutually exclusive dependencies, something like

depends_on_either "postgresql" => :recommended,
                  "libpq" => :optional

This is more of a proposal to brew itself…
so you can install brew install <formulae> --with-libpq in order to use that alternative dependency,

any thoughts?


(Juan Ignacio Donoso) #7

I just thought that I could something like this:

option "with-libpq", "Use libpq"

if build.with? "libpq"
    depends_on "libpq"
    depends_on "postgresql" => :recommended 

If I run brew install <formulae> it will install the recommended dependency (postgresql)
If i run brew install <formulae> --without-postgresql i can still install the formulae without the recommended dependency.
If i run brew install <formulae> --with-libpq it will install libpq instead.

Is this too ugly???


(Mike McQuaid) #8

If it doesn’t need postgresql I agree a libpq dependency is a better/lighter option. You definitely don’t want to do conditional if build.with? dependencies as they don’t work as expected. You shouldn’t need to force link a dependency; just add the necessary include/library paths to find the opt_prefix for the keg_only formula.


(Juan Ignacio Donoso) #9

It just need the postgresql cli tools on the path… nothing to include at build time… just dropdb, pg_loader… stuff like that…

well, thanks for your time and feedback