LoginSignup
1
0

[Gem][Rails][Postgresql] gem pg がinstallできない (Your version of PostgreSQL (9.2.22) is too old) 解決法

Posted at

概要

Centos 7に Rails にgem 'pg' を入れたい。
そのままyum install postgresql-server だとversion 9.2 が入るが、(以下)
最近の gem 'pg' を使うには >9.3 である必要があるため、エラー

$ bundle install
...
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to
at least PostgreSQL-9.2.
Error..

補足

CentOS 7 にpostgresql-15 installの流れは以下。

# Install the repository RPM:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Install PostgreSQL:
sudo yum install -y postgresql15-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15

もし古い postgresql が残っていたら削除

$ yum list installed | grep postgre
postgresql.x86_64                15.6-1PGDG.rhel7              @pgdg
postgresql-devel.x86_64          15.6-1PGDG.rhel7              @pgdg
postgresql-libs.x86_64           15.6-1PGDG.rhel7              @pgdg
postgresql-server.x86_64         15.6-1PGDG.rhel7              @pgdg

$ sudo yum remove postgresql postgresql-libs -y

解決法

(↑で) 最新の version 15を入れた後、
以下で confiを指定して、実行すれば bundle install が通る

bash
$ bundle config build.pg --with-pg-config=/usr/pgsql-15/bin/pg_config # 15 が入っている前提
$ bundle
...
OK
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0