3

I have difficulty trying to gem install pg -v '0.18.4' that is needed for my ruby on rails "bundle install" app which was developed about 3 years back.

sudo gem install pg -v '0.18.4'

it complaints below:

conftest.c:15:13: error: conflicting types for 'PQconnectdb'
extern void PQconnectdb();

full execution error https://gist.github.com/axilaris/f521685f4e5c7a8e5653bf672af1efa7

mkmf.log - https://gist.github.com/axilaris/2e4cf2729b34d751c1ce76b046a0b21c

My environment is as below:

Postgres 9.4.0.1
MacOs Sierra High 10.13.1

$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]

$ rails -v
Rails 5.1.4

I tried to install brew install libpqxx it doesnt work

Here are some related stackoverflow:

Can't find the 'libpq-fe.h header when trying to install pg gem

Impossible to Install PG gem on my mac with Mavericks

I want to make sure I install - sudo gem install pg -v '0.18.4'. Since on production it should be running that as well. I dont want to break anything that is running in the production ubuntu server. Currently for this question, I am setting up the environment on my mac for development to try to make a code fix.

FYI, I'ved tried on 2 macs. one original development mac which upgraded to sierra high, another is a new formatted mac with newly installed sierra high.

Axil
  • 3,606
  • 10
  • 62
  • 136
  • Please let me know the result of `brew install postgresql`. and If you don't have homebrew do this `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"` – Ajay Barot Jan 16 '18 at 12:34
  • its already installed, so it complaints this https://gist.github.com/axilaris/daa8c7831870ed4f41e20e5ecefef7da. Im a bit afraid of uninstalling it, since i have my development environment, will it remove existing db – Axil Jan 16 '18 at 23:57
  • Open `gemfile.lock` and search pg and let us know the gem version of pg. – Ajay Barot Jan 17 '18 at 06:06
  • this is the gemfile.lock https://gist.github.com/axilaris/163e4a68360acd33438a545fbaab6029. pg (0.18.4) – Axil Jan 17 '18 at 06:08
  • Please try this `sudo gem install pg -v '0.18.4' -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/10.1/bin/pg_config` – Ajay Barot Jan 17 '18 at 06:18
  • thanks for helping out, but still the same problem. execution error - https://gist.github.com/axilaris/486b3708396d2e54a3f278550d7ac6a0 mkmf.log - https://gist.github.com/axilaris/40a3e9f4b652cae711e409b529713260 – Axil Jan 17 '18 at 06:24
  • You are welcome. path of pg_config is wrong. find the pg_config path using this command `find /Applications -name pg_config`. and add that path in `with-pg-config=`. – Ajay Barot Jan 17 '18 at 06:33
  • its the same error. https://gist.github.com/axilaris/5e16e1b569642f6fde9c885a6694a649. maybe it maybe wise to reinstall this ? https://postgresapp.com/. generally i have been using postgres app for my development mac postgress db.this db is still working, my django is using it without problems and my previous ror until now. – Axil Jan 17 '18 at 06:56
  • it doesnt work even if i install latest postgresapp.com, even on a clean mac machine, for some reason PQconnectdb does not exist in any of -lpq, -llibpq, -lms/libpq – Axil Jan 17 '18 at 07:55
  • 1
    Try this `ARCHFLAGS="-arch x86_64" gem install pg -v '0.18.4'` – Ajay Barot Jan 17 '18 at 08:32
  • i did try that but failed, even with - env ARCHFLAGS="-arch x86_64" gem install pg -v '0.18.4' – Axil Jan 17 '18 at 08:35
  • where does -lpq, -llibpq, -lms/libpq comes from ? – Axil Jan 17 '18 at 08:35
  • we have to install those packages. what is error in `brew install libpqxx`? – Ajay Barot Jan 17 '18 at 08:47
  • there is no error installing libpqxx. sudo gem install pg still complains the same error. https://gist.github.com/axilaris/d493d3b109b470752fcffbc2b338e92c – Axil Jan 17 '18 at 12:35
  • just to verify, im using x86_64 architecture. https://gist.github.com/axilaris/4eb73d9096e639eaff773611cc7f7a1e – Axil Jan 17 '18 at 12:51
  • this worked! ARCHFLAGS="-arch x86_64" bundle install. now there is "Can't install RMagick 2.15.4" issue. anyway this is solved. tqvm for your support – Axil Jan 17 '18 at 13:14

1 Answers1

5

Try this

ARCHFLAGS="-arch x86_64" bundle install

For RMagick do this

brew install imagemagick@6
brew link --force imagemagick@6

Please let me know if any error occur in while installing rmagick.

Ajay Barot
  • 1,681
  • 1
  • 21
  • 37
  • it didnt work with rmagick after using your commands for imagemagick@6 https://gist.github.com/axilaris/59a602402149a12b97d6e3b018d9ea03 – Axil Jan 17 '18 at 13:46
  • @Axil: Try this `PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig gem install rmagick` – Ajay Barot Jan 17 '18 at 16:11
  • 1
    this was the reason. brew link --force imagemagick@6 needed to be executed again. thank you. bundle install now completes! – Axil Jan 17 '18 at 21:47
  • 1
    Can you change the answer to this >>> ARCHFLAGS="-arch x86_64" bundle install. – Axil Jan 18 '18 at 01:50
  • 1
    ARCHFLAGS="-arch x86_64" bundle install Worked for mac os X – Water223 Jun 25 '18 at 23:29