sqitchers / homebrew-sqitch

Homebrew Formulas for Sqitch
22 stars 10 forks source link

Failing to brew install sqitch--with-postgres-support --without-postgresql #45

Closed jraines closed 3 years ago

jraines commented 5 years ago

After tapping the keg, brew install --with-postgres-support --without-postgresql fails with the following message:

! Installing the dependencies failed: Module 'DBD::Pg' is not installed

I tried cpan TURNSTEP/DBD-Pg-3.10.0.tar.gz which seemed to succeed, but get the same error from brew install sqitch --with-postgres-support --without-postgresql

OSX High Sierra 10.13.6 Postgres installed, separately & prior to this, via brew install postgres@9.5

theory commented 5 years ago

Try installing it with cpanm, which is what the formula uses. Also, it should be putting errors in a directory and report that directory; have a look there.

jraines commented 5 years ago

Thanks.

I did cpanm TURNSTEP/DBD-Pg-3.10.0.tar.gz which again seemed to succeed.

brew install sqitch --with-postegres-support --without-postgresql

fails with the same error, and digging into the log as you suggest I see this:

! Configure failed for DBD-Pg-3.10.0. See /private/tmp/sqitch-20190922-4159-555but/App-Sqitch-v1.0.0/.brew_home/.cpanm/work/1569193756.8658/build.log for details.

but trying to dig into the next referenced log does not work:

tail -n500 /private/tmp/sqitch-20190922-4159-555but/App-Sqitch-v1.0.0/.brew_home/.cpanm/work/1569193756.8658/build.log
tail: /private/tmp/sqitch-20190922-4159-555but/App-Sqitch-v1.0.0/.brew_home/.cpanm/work/1569193756.8658/build.log: No such file or directory
theory commented 5 years ago

Uhhhh…since you're building against your own install of Postgres, it could be that it's not finding pg_config, possibly because Homebrew resets a bunch of environment variables when it runs. Is pg_config in your path?

jraines commented 5 years ago

It is:

❯ which pg_config
/usr/local/opt/postgresql@9.5/bin//pg_config

I thought the double slashes were odd so I ran it, and it seemed to be correct (output a bunch of Postgres related env vars)

I have some vague mental associations with problems like this being related to C compiler.

Among the vars output by pg_config is CC = clang

I have both clang and gcc on my path. Does this seem like a relevant datapoint at all?

theory commented 5 years ago

LOL, yes, make sure you have it set up to use the same compiler used to build Perl and Postgres, if possible. I mean, it shouldn't make too much difference, but maybe? Also, do you have a complete install of Postgres with the libpq libraries? I presume you do since you installed DBD::Pg manually okay. With that in mind, does this command emit an error?

perl -MDBD::Pg -E 'say 1'

And is that the same Perl as Homebrew user?

jraines commented 5 years ago

That command does not emit an error.

As far as I can tell it's the same perl (but I'm just comparing perl -v to brew info perl)

I don't know about "a complete install of Postgres with libpq libraries". I installed Postgres with brew install postgres@9.5. I couldn't confirm that I did have it so I installed it with brew install libpq and added the following lines to my shell profile:

export LDFLAGS="-L/usr/local/opt/libpq/lib"
export CPPFLAGS="-I/usr/local/opt/libpq/include"

Still no luck. I have not symlinked libpq yet, per these Homebrew post install instructions:

==> Caveats
libpq is keg-only, which means it was not symlinked into /usr/local,
because conflicts with postgres formula.

If you need to have libpq first in your PATH run:
  echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile

For compilers to find libpq you may need to set:
  export LDFLAGS="-L/usr/local/opt/libpq/lib"
  export CPPFLAGS="-I/usr/local/opt/libpq/include"

I didn't add it to the path because it looks like it adds all the administrative pg commands, so I guess that's why it conflicts . . . and seems to confirm I did have it before (idk)

theory commented 5 years ago

Right, it conflicts because Postgres also includes libpq (it gets built by default, I'm certain Homebrew includes it).

ISTR that Homebrew always removes the directory in which cpanm leaves the log file. Can you try again using brew install --keep-tmp --with-install-debug? You should be able to get at the cpanm log file after that.

theory commented 3 years ago

In 2b5c757, I've changed the formula so that --verbose gets passed through, so try running with --verbose and see if you get any more useful information.

halostatue commented 3 years ago

We just ran into this issue ourselves. We were able to solve it with:

brew install libpq
brew link libpq --force
brew install sqitch --with-postgresql-support --without-postgres
brew unlink libpq
theory commented 3 years ago

Oh interesting. I guess the issue is that the installed Postgres is binary only, no libraries or headers (or else no paths to them), so DBD::Pg compilation fails.

halostatue commented 3 years ago

Yeah. We only have postgresql@9.6 installed ourselves, because that’s the version we have for our currently deployed applications (trying to figure out our upgrade path…), so it might work with brew link postgresql@9.6 --force.

theory commented 3 years ago

Hrm. I wonder if the formula could be changed to require libpq at build time when --without-postgres is specified…

theory commented 3 years ago

Does this fix the issue?

--- a/Formula/sqitch.rb
+++ b/Formula/sqitch.rb
@@ -31,6 +31,7 @@ class Sqitch < Formula

   if build.with? "postgres-support"
     depends_on 'postgresql' => :recommended
+    depends_on "libpq" => :build
   end

   if build.with? "sqlite-support"
halostatue commented 3 years ago

I’ll have to test this later, but I suspect it will help.

theory commented 3 years ago

Seems pretty safe to add, so went ahead and pushed fecb81e. Please do reopen if it doesn't correct the issue, though.