ERROR: Failed to buil gem native extension because PostgreSQL is too old - ruby-on-rails

I'm attempting to run bundle in my Rails project on Mavericks. It fails when getting to the pg gem with this error.
It said Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database.. so I installed postgresql-9.3.4 and gem install gem but same error occurred.
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/path/to/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/php5/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/path/to/.rvm/rubies/ruby-2.1.1/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
extconf failed, exit code 1
Thanks in advance.

Try adding your postgresql installation to your path:
export PATH=/usr/pgsql-9.3.4/bin:$PATH

Related

How to install gem pg on mac mini m1?

I'm having trouble installing gem pg on my m1 mac mini. Im trying to host onto Heroku and netlify. Wondering if anyone has found a workaround for this. I have tried several solutions on stack overflow but nothing works.
please help, I consider myself a noob with this kinda stuff.
below is the error im getting.
`
jonathanbleibdrey#Little-Mac listen_to_the_humans % gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3/ext
/Users/jonathanbleibdrey/.rvm/rubies/ruby-2.6.1/bin/ruby -I /Users/jonathanbleibdrey/.rvm/rubies/ruby-2.6.1/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210323-28582-1dv0k5o.rb extconf.rb
checking for pg_config... yes
Using config values from /opt/homebrew/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/jonathanbleibdrey/.rvm/rubies/ruby-2.6.1/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/extensions/x86_64-darwin-19/2.6.0/pg-1.2.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/gems/pg-1.2.3 for inspection.
Results logged to /Users/jonathanbleibdrey/.rvm/gems/ruby-2.6.1/extensions/x86_64-darwin-19/2.6.0/pg-1.2.3/gem_make.out
`
let me know what I can do or resources I can find, or even if we can zoom to fix it wanted to launch it by need of week.
The key to my initial problem getting pg gem to install on my m1 was that installing postgresql via brew did not install a library that the pg gem needs to run. This fixed it:
brew install libpq
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
gem install pg
Figured it out: I had some dependency's in my homebrew that was out of date. all I had to do is
homebrew upgrade
I think.

Impossible to install postgres gem on my mac with OS X/Yosemite

I've seen this question posted dozens of times across a bunch of different sites, with lots of different answers--none of which seems to work.
I'm trying to install the 'pg' gem on my Mac (OS X/Yosemite), but keep getting the following error:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
I've already tried reinstalling Postgres with $ brew install postgresql, using sudo gem install pg, and upgrading xcode using xcode-select --install.
Any insight on what this means would be very helpful.

Bundle install pg wont work, mac os yosemite. I have tried everything

I have a rails app that I want to start working on, but I just can't get past this one error. I cannot install the pg -v -0.10.1 gem I have tried reinstalling Postgressql from my entire system and that didn't work. I have tried to run the command below and it works successfully but I still can't run bundle install successfully.
env ARCHFLAGS="-arch x86_64" gem install pg
I followed the instructions of this thread step by step but no cigar.
I just keep getting the error message below.
`Building native extensions with: '--with-pg-config= /usr/local/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config= /usr/local/bin/pg_config
Using config values from
sh: : command not found
sh: : command not found
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
enter code here
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.18.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/pg-0.18.2/ext/gem_make.out`

Error installing gem `pg` on OSX 10.9.5 with Xcode 6.0.1

Problems running bundle install and rails s will not load properly...have tried everything I could find on old Stackoverflow posts on similar issues to no avail.. error below.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20140930-556-1w549j8.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
extconf failed, exit code 1
Any help would be greatly appreciated!
The problem is that you don't have pg installed. The first step is to install Postgres.
Do that here: http://postgresapp.com/
Next step is to install the pg gem with the required config files. Do that like this:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
You might have to change the path a bit to point to the right place.

My project Ruby On Rails cannot install gem postgre in CentOS 6.2

Although many sources of references from stackoverflow but my problem has not been resolved. When I run My project (ProjectJapanFull_New) on window server it no problem, but when I switched it to CentOS server 6.2 is an error, namely:
[root#links02 ProjectJapanFull_New]# rails -v
You have requested:
pg >= 0
The bundle currently has pg locked at 0.17.0.
Try running `bundle update pg`
Run `bundle install` to install missing gems.
Then I run: bundle install another error show:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p547/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p547/extensions/x86_64-linux/1.9.1/pg-0.17.0/gem_make.out
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.
When i run gem install pg -v '0.17.0' show this error:
[root#links02 ProjectJapanFull_New]# gem install pg -v '0.17.0'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
extconf failed, exit code 1
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p547/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p547/extensions/x86_64-linux/1.9.1/pg-0.17.0/gem_make.out

Resources