[Ruby On Rails] pg Gem 설치 오류 해결하기
Permission 접근이 금지되었다고 나옵니다. sudo 로 권한을 줘 봅시다.
$ sudo gem install pg
Password:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/Chipmunk/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pg-1.0.0/ext
/Users/Chipmunk/.rbenv/versions/2.4.0/bin/ruby -r ./siteconf20180521-5009-tgjz9b.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=/Users/Chipmunk/.rbenv/versions/2.4.0/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
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/Chipmunk/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0-static/pg-1.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/Chipmunk/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/pg-1.0.0 for inspection.
Results logged to /Users/Chipmunk/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/extensions/x86_64-darwin-17/2.4.0-static/pg-1.0.0/gem_make.out
또 알 수 없는 이유로 pg 젬 인스톨에 실패합니다!
pg_config 를 찾을 수 없고, libpq-fe.h 헤더도 찾을 수 없다고 나옵니다.
이를 해결하기 위해서는 다음의 방법이 있습니다.
Mac OS 내에서 'postgresql' 을 설치해줘야 합니다.
postgresql 을 설치하기 위해서, 맥 패키지 매니저인 HomeBrew 를 설치해야 합니다.
터미널에 아래 코드를 쳐 주세요.
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
그런 다음 postgresql 을 인스톨합시다!
$ brew install postgresql
==> Downloading https://homebrew.bintray.com/bottles/postgresql-10.4.high_sierra
Already downloaded: /Users/Chipmunk/Library/Caches/Homebrew/postgresql-10.4.high_sierra.bottle.tar.gz
==> Pouring postgresql-10.4.high_sierra.bottle.tar.gz
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Summary
🍺 /usr/local/Cellar/postgresql/10.4: 3,389 files, 39.2MB
그런 다음 다시 관리자 권한을 줘서 bundle install 해봅시다!
$ sudo bundle install
Fetching pg 1.0.0
Installing pg 1.0.0 with native extensions
Bundle complete! 19 Gemfile dependencies, 82 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
혹 그럼에도 설치가 안되신다면, 다음의 문서를 참고해 주시길 바랍니다.
$ sudo ARCHFLAGS="-arch x86_64" gem install pg
'Back-End > Back-End 자료실' 카테고리의 다른 글
Backend Interview Q1. 프로세스와 스레드의 차이 (1) | 2020.08.25 |
---|---|
[Laravel] MySQL 8.0 이상 인증 오류 해결 (0) | 2018.09.25 |
REST API: PUT & PATCH (0) | 2018.05.08 |
REST API: POST & PUT (0) | 2018.05.08 |
CoC (Convention over Configuration) (0) | 2018.05.08 |
댓글