IT TIP

gem install pg --with-pg-config 작동, 번들 실패

itqueen 2020. 11. 2. 20:13
반응형

gem install pg --with-pg-config 작동, 번들 실패


실행할 때 (루트 권한으로)

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config

다음 출력이 표시됩니다.

#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Building native extensions.  This could take a while...
Successfully installed pg-0.12.0
1 gem installed
Installing ri documentation for pg-0.12.0...
Installing RDoc documentation for pg-0.12.0...
#-> 

번들 설치를 실행할 때 :

Installing pg (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.2-p290/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
--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.2-p290/bin/ruby
--with-pg
--without-pg
--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-pg-config
--without-pg-config
--with-pg_config
--without-pg_config


Gem files will remain installed in /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-    0.12.0 for inspection.
Results logged to /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-0.12.0/ext/gem_make.out
An error occured while installing pg (0.12.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling.

/usr/pgsql-9.1/include/libpq-fe.h에 libpq-fe.h가 설치되어 있습니다. 그래서 나는 시도했다

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config --with-pg-lib=/usr/pgsql-9.1/include/libpq-fe.h but still no go. 

어떤 도움이라도 대단히 감사하겠습니다.

또한 postgresql91-devel 및 ruby-devel을 설치했습니다. CentOS 6 실행


실행하기 전에 실행 해 보셨습니까 bundle install?

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

http://bundler.io/v1.3/bundle_config.html 참조


누군가 macports를 사용하여 postgres를 설치하고 pg_config를 찾는 데 문제가있는 경우 다음을 시도하십시오.

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config

누군가가 시간을 절약하는 데 도움이되기를 바랍니다. 건배!


pg_config가 어디에 있는지 확실하지 않고 Linux 또는 Mac에 있다고 가정하면 다음 명령을 실행할 수 있습니다.

which pg_config

이 반환됩니다 ==> /usr/pgsql-9.1/bin/pg_config

이제이 경로를 다음과 같이 사용하십시오.

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config

지금 완료 bundle install


libpq-dev를 설치하여 동일한 문제가 해결되었습니다.

Ref: https://bitbucket.org/ged/ruby-pg/issue/83/help-gem-install-pg-failed-on-opensuse-103


Copy & Paste:

bundle config build.pg --with-pg-config=`which pg_config` && bundle

Details:

Visit for more information:

The first thing you should do is ensure that the 'pg_config' tool that comes with Postgres is in your path. If it isn't, or the one that's first in your path isn't the one that was installed with the Postgres you want to build against, you can specify the path to it with the –with-pg-config option.

Source: https://github.com/ged/ruby-pg/blob/1f274f68c16f1af1c642db1b9d3d28aef169dc84/ext/extconf.rb#L27


You can get this error if you have pg_config installed but its not in any path. You can add it to your PATH env in your ~/.bashrc.

For example.

export PATH=${PATH}:/usr/pgsql-9.2/bin

I'm on Mac and i use Homebrew, so to fix this issue i just installed postgresql with brew:

brew install postgresql

And then installed the gem.


I had to do this to fix mine on OS X:

export PATH=/opt/local/lib/postgresql84/bin/:$PATH

And I had to do it despite the fact that I already had this in my path:

[user@foo ~] which psql84
/opt/local/bin/psql84

[user@foo ~] ls -altrh /opt/local/bin/psql84 
lrwxr-xr-x  1 root  admin    36B Dec  7 02:15 /opt/local/bin/psql84 ->  /opt/local/lib/postgresql84/bin/psql

I hope that helps another Mac user with this problem.


The Postgres gem can't find the Postgres configuration file. You need to tell it where it is. The most enjoyable solution to this in my opinion is to skip Brew and MacPorts and just use the Postgres app. Download and install from here:

http://postgresapp.com/

Now add the bin folder to your path:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

You may also wish to add this to your ~/.bash_profile

Now install the gem:

gem install pg

it should go smoothly.


I am using Arch Linux, and was having similar problems. Used sudo pacman -S libpqxx and reran then installed the pg gem and then ran bundle install again, and this time it finally worked!


Try this:

yum install libpqxx-devel

It works with Postgr9.2.


When do you use postgresapp on Mac, read the http://postgresapp.com/documentation/cli-tools.html documentation and Configure your $PATH. Before this try run the bundle install again.


This link suggested using:

gem install pg --pre

I couldn't get the pg gem to install for days,but this method finally worked for me. Hope this will be helpful.


gem install pg -v '0.17.1'

Did the trick for me.


Make sure you have postgress installed. if not install it first. Using terminal for example.

brew install postgresql

After that run

bundle install

Somes cases on UBUNTU

sudo apt-get install libpq-dev

On CentOS 7

sudo yum install postgresql-devel

Then

bundle install

this worked for me.


in OSX, first install pg:

brew install postgresql

second, do gem install:

gem install pg --source 'https://rubygems.org/'

you can then run bundle install


I am using mac and didn't want to install postgresql locally.

Installing libpq and setting the bundler config worked for me.

Reference link

참고URL : https://stackoverflow.com/questions/9234960/gem-install-pg-with-pg-config-works-bundle-fails

반응형