IT

Rails 3-pg gem을 사용할 수 없습니다.

lottoking 2020. 8. 24. 20:41
반응형

Rails 3-pg gem을 사용할 수 없습니다.


항상 (번들 설치)를 실행하려고하면

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

        /Users/ryan/.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
    --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=/Users/ryan/.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 /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2 for inspection.
Results logged to /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
An error occured while installing pg (0.13.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.13.2'` succeeds before bundling.

Mac OS X 10.6을 사용하고 있으며 PostgreSQL 버전은 9.1. 문제가 libpq-dev 에 있음을 발견했습니다 . 어떻게 설치되어 있습니까?


pg_config의 경로를 전달해야합니다. 다음을 사용하여 gem을 설치하십시오.

gem install pg -- --with-pg-config= 'PATH_TO_YOUR_PG_CONFIG'

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

which pg_config

pg-config는 postgres를 설치 한 방법에 따라 다른 위치에 있습니다.


Linux에서 실행중인 경우 저에게 효과가있는 것에 관심이 있습니다.

sudo apt-get install postgresql
sudo apt-get install libpq-dev

그때

gem install pg

그때

bundle install

소스 : http://wikimatze.de/installing-postgresql-gem-under-ubuntu-and-mac


Postgress.app사용하는 경우 명령 줄 도구에 액세스해야 합니다 . 터미널 또는 PATH 프로필 에 다음 줄을 입력합니다 .

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

gem install pg이제 작동합니다. (이것은 나를 위해 일한 것입니다.)

참고 새 버전 경로는 다음과 같습니다.

/Applications/Postgres.app/Contents/Versions/<version>/bin


homebrew가있는 경우 다음을 입력하십시오.

$ brew install postgresql

가지고 있지 않다면 터미널에 다음을 입력하여 다운로드하십시오.

루비 -e "$ (curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install )"


libpq 검색 :

brew search libpq

출력해야 함 libpqxx

그런 다음 설치해보십시오.

brew install libpqxx

다음 만 설치하면됩니다 libpq-dev.

sudo apt-get install libpq-dev

그러면 gem이 잘 설치됩니다.


설치 후 지침을 따르십시오 : http://postgresapp.com/documentation/configuration-ruby.html

pg gem을 설치하려면 $ PATH를 올바르게 설정했는지 확인한 다음 ( http://postgresapp.com/documentation/cli-tools.html에 지정된대로 ) 다음을 실행합니다.

sudo ARCHFLAGS="-arch x86_64" gem install pg

나는 강하게 두 페이지를 읽어 보시기 바랍니다. 그냥 훑어보고 내 인생의 1 시간을 잃었습니다. 그것들을 읽으면 문제가 해결됩니다.


내가 가진 문제는 어떤 이유로 /usr/bin/gcc-4.2로 컴파일하려고 시도했다는 것입니다. 실패한 컴파일 라인에서 예외를 발생시키기 위해 mkmf.rb (스택 추적에서 보았습니다)의 try_cpp를 변경하여 발견했습니다.

gcc를 gcc-4.2에 소프트 링크했고 작동했습니다.

sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

gcc-4.2를 사용하려는 이유는 무엇입니까? 몰라요.

실제 컴파일 라인 :

/usr/bin/gcc-4.2 -E -I/Users/dfrankow/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin11.4.0 -I/Users/dfrankow/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/backward -I/Users/dfrankow/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/usr/local/Cellar/postgresql/9.1.4/include  -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration  -fno-common -pipe  conftest.c -o conftest.i (RuntimeError)

같은 문제가 발생했지만 Postgres가 설치되었습니다.

/Library/PostgreSQL/9.3

다음을 추가하여 ~ / .bash_profile을 업데이트했습니다.

export PATH=/Library/PostgreSQL/9.3/bin:$PATH

새 터미널을 열고 실행 bundle update하면 저에게도 효과적이었습니다. 고마워 아리.


빌드 구성 옵션을 설정하고 옵션 없이 bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config사용할 gem install pg수 있습니다 (pg_config에 대한 경로가 다를 수 있습니다.이 경로는 Postgresapp 9.3.5.0 용입니다).


openSUSE13.1 KDE 시스템에서 동일한 문제가 발생했습니다. 그 문제가 발생하기 전에 나는 패키지 만 설치 postgresql하고 명령을 postgresql-server사용했습니다 zypper. 그런 다음 다시 2 개의 패키지를 설치했습니다.

[arup@to_do_app]$ sudo zypper in postgresql-devel postgresql-contrib
root's password:
Loading repository data...
Reading installed packages...
Resolving package dependencies...
#....

그리고 다시 bundle install뛰고 성공 !!!


작동하는 OSX 솔루션에 대해서는이 가이드 http://krugerdavid.com/journal/how-to-install-xcode-homebrew-git-rvm-postgresql-ruby-1-9-3-on-snow-leopard/를 참조하십시오.

homebrew를 사용하여 PostgreSQL을 설치하는 과정을 안내합니다. OSX 10.8.3, PostgreSQL 9.2.3 및 Ruby 2.0.0-p0에서 나를 위해 테스트하고 작업했습니다.


먼저 Homebrew 버전을 제거하십시오. --force 옵션은 모든 버전을 제거합니다.

brew rm postgresql --force

버전에 따라 경로를 변경하십시오.

sudo /sbin/SystemStarter stop postgresql-8.4
sudo rm -rf /Applications/PostgreSQL\ 8.4
sudo rm -rf /etc/postgres-reg.ini
sudo rm -rf /Library/StartupItems/postgresql-8.4
sudo rm -rf /Library/PostgreSQL/8.4
sudo dscl . delete /users/postgres

/ etc / profile을 편집하고 "postgres"를 참조하는 모든 줄을 삭제합니다.

nano /etc/profile

PostgresSQL 설치

brew update
brew install postgresql

PG GEM 설치

gem install pg

그게 다야. 문안 인사.


먼저 lib 파일로 이동하여 터미널에 postrgresql 파일이 있는지 확인할 수 있습니다. cd ~ / opt / local / lib /로 이동 한 다음 ls를 입력하고 Enter 버튼을 누릅니다. 그러면 lib 디렉토리에있는 모든 파일 목록이 표시됩니다.

1. postreseql이없는 경우 macports를 통해 다운로드 할 수 있습니다. sudo 포트 설치 postgresql93 @ 9.3.2_1

이제 번들 설치를 시도하는 폴더로 CD를 다시 넣으십시오.

  1. pg가 postgesql 파일과 함께 작동하도록하거나 방금 다운로드 한 gem install pg---with-pg-config = / opt / local / lib / postgresql93 / bin / pg_config

이제 번들 설치를 실행하십시오.


Fedora에서 :

dnf install postgresql-devel

El Capitan에서 나를 위해 일한 것은 시스템 기본값에서 2.3.1로 루비를 업그레이드하는 것이 pggem에 필요한 올바른 라이브러리를 찾는 것 같습니다 .

참고 URL : https://stackoverflow.com/questions/9668753/rails-3-cant-install-pg-gem

반응형