0
votes

Hi could someone please help me! Appreciate it a lot!

I have some problem bundle install because the terminal says I fail to install gem pg v 0.20.0 When I tried to install the gem pg this error occurs. I'm currently using PostgreSQL 9.6 I have tried through all the solutions in the similar question but nothing works, including trying to reconfigure pg.

198-195:Review minhvu$ gem install pg -- --with-pg-config=/usr/pgsql-9.6/bin/pg_config Building native extensions with: '--with-pg-config=/usr/pgsql-9.6/bin/pg_config' This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.

current directory: /Users/minhvu/.rvm/gems/ruby-2.3.0/gems/pg-0.20.0/ext /Users/minhvu/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20170313-7016-1if947v.rb extconf.rb --with-pg-config=/usr/pgsql-9.6/bin/pg_config Using config values from /usr/pgsql-9.6/bin/pg_config sh: /usr/pgsql-9.6/bin/pg_config: No such file or directory sh: /usr/pgsql-9.6/bin/pg_config: No such file or directory * 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/minhvu/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME) --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}/lib /Users/minhvu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/mkmf.rb:456:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/minhvu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/mkmf.rb:541:intry_link0' from /Users/minhvu/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/mkmf.rb:556:in try_link' from extconf.rb:40:in'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

/Users/minhvu/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-16/2.3.0/pg-0.20.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/minhvu/.rvm/gems/ruby-2.3.0/gems/pg-0.20.0 for inspection. Results logged to /Users/minhvu/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-16/2.3.0/pg-0.20.0/gem_make.out

1

1 Answers

1
votes

It seems to me, that you are trying to installing pg gem, but first you should install PostgreSQL in your system. Depending of what system you have you should follow the instructions in this post. I am quoting the answer from addicted Addicted user at the following post

Rails Error Installing PG

Steps to install

  1. Install PostgreSQL and its libraries
    sudo apt-get install postgresql postgresql-contrib libpq-dev
  1. After the installation create a user for postgresql
    sudo -u postgres createuser --superuser $USER

or

    sudo -u postgres createuser pgs_root
  1. Set user password for the postgresql user
    sudo -u postgres psql postgres ( For psql prompt) postgres=# \passsword for ex.-      postgres=# \passsword pgs_root
  1. Configure the postgresql.conf file to make PostgreSQL listen to localhost or listen on an external IP or something, change this line to either the IP or 'localhost'
     gedit /etc/postgresql/8.4/main/postgresql.conf listen_addresses = 'localhost