質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

1回答

1806閲覧

RubyonRails gem install pg ができない

TOMSOYA

総合スコア23

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2019/05/06 23:35

編集2019/05/06 23:43

前提・実現したいこと

プログラミング初心者です。gem 'pg'をインストールしようとしましたがエラーが出てインストールできない問題を解決したいです。OSはCentOSです。

発生している問題・エラーメッセージ

bundle installを実行すると以下のエラーが発生してしまいます。
少し長くなってしまします。

Your Gemfile lists the gem pry-rails (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once (per group). While it's not a problem now, it could cause errors if you change the version of one of them later. The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Fetching gem metadata from https://rubygems.org/........ Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.3.2 Using CFPropertyList 2.3.6 Using concurrent-ruby 1.1.5 Using i18n 1.6.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.2.3 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.2 Using rails-dom-testing 2.0.3 Using crass 1.0.4 Using loofah 2.2.3 Using rails-html-sanitizer 1.0.4 Using actionview 5.2.3 Using rack 2.0.7 Using rack-test 1.1.0 Using actionpack 5.2.3 Using nio4r 2.3.1 Using websocket-extensions 0.1.3 Using websocket-driver 0.7.0 Using actioncable 5.2.3 Using globalid 0.4.2 Using activejob 5.2.3 Using mini_mime 1.0.1 Using mail 2.7.1 Using actionmailer 5.2.3 Using activemodel 5.2.3 Using arel 9.0.0 Using activerecord 5.2.3 Using mimemagic 0.3.3 Using marcel 0.3.3 Using activestorage 5.2.3 Using public_suffix 3.0.3 Using addressable 2.6.0 Using io-like 0.3.0 Using archive-zip 0.12.0 Using bcrypt 3.1.12 Using coderay 1.1.2 Using better_errors 2.5.1 Using bindex 0.7.0 Using msgpack 1.2.9 Using bootsnap 1.4.3 Using bundler 2.0.1 Using byebug 11.0.1 Using regexp_parser 1.4.0 Using xpath 3.2.0 Using capybara 3.15.0 Using mime-types-data 3.2019.0331 Using mime-types 3.2.2 Using carrierwave 1.3.1 Using childprocess 1.0.1 Using chromedriver-helper 2.1.1 Using coffee-script-source 1.12.2 Using execjs 2.7.0 Using coffee-script 2.4.1 Using method_source 0.9.2 Using thor 0.20.3 Using railties 5.2.3 Using coffee-rails 4.2.2 Using unf_ext 0.0.7.6 Using unf 0.1.4 Using domain_name 0.5.20180417 Using dry-inflector 0.1.2 Using excon 0.64.0 Using ffi 1.10.0 Using fission 0.5.0 Using formatador 0.2.5 Using fog-core 1.45.0 Using multi_json 1.13.1 Using fog-json 1.2.0 Using ipaddress 0.8.3 Using xml-simple 1.1.5 Using fog-aliyun 0.3.3 Using fog-xml 0.1.3 Using fog-atmos 0.1.0 Using fog-aws 2.0.1 Using fog-brightbox 0.16.1 Using fog-cloudatcost 0.1.2 Using fog-digitalocean 0.4.0 Using fog-dnsimple 1.0.0 Using fog-dynect 0.0.3 Using fog-ecloud 0.3.0 Using fog-google 0.1.0 Using fog-internet-archive 0.0.1 Using fog-joyent 0.0.1 Using fog-local 0.6.0 Using fog-openstack 0.3.10 Using json 2.2.0 Using ovirt-engine-sdk 4.3.0 Using http-cookie 1.0.3 Using netrc 0.11.0 Using rest-client 2.0.2 Using rbovirt 0.1.7 Using fog-ovirt 1.1.6 Using fog-powerdns 0.2.0 Using fog-profitbricks 4.1.1 Using fog-rackspace 0.1.6 Using fog-radosgw 0.0.5 Using fog-riakcs 0.1.0 Using fog-sakuracloud 1.7.5 Using fog-serverlove 0.1.2 Using fog-softlayer 1.1.4 Using fog-storm_on_demand 0.1.1 Using fog-terremark 0.1.0 Using fog-vmfusion 0.1.0 Using fog-voxel 0.1.0 Using optimist 3.0.0 Using rbvmomi 2.1.1 Using fog-vsphere 3.0.0 Using xmlrpc 0.3.0 Using fog-xenserver 1.0.0 Using fog 1.42.0 Using jbuilder 2.8.0 Using rb-fsevent 0.10.3 Using rb-inotify 0.10.0 Using ruby_dep 1.5.0 Using listen 3.1.5 Using mini_magick 4.9.3 Fetching pg 1.1.4 Installing pg 1.1.4 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-1.1.4/ext /home/vagrant/.rbenv/versions/2.3.1/bin/ruby -I /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0 -r ./siteconf20190506-11340-14f31rf.rb extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes checking for pg_config_manual.h... yes checking for PQconnectdb() in -lpq... yes checking for PQsetSingleRowMode()... no Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to at least PostgreSQL-9.2. *** 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=/home/vagrant/.rbenv/versions/2.3.1/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 --with-pqlib --without-pqlib To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-1.1.4/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-1.1.4 for inspection. Results logged to /home/vagrant/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-1.1.4/gem_make.out An error occurred while installing pg (1.1.4), and Bundler cannot continue. Make sure that `gem install pg -v '1.1.4' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: pg

該当のソースコード

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.3.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.3' # Use sqlite3 as the database for Active Record gem 'sqlite3', group: :development # 本番ではpostgressを使用する gem 'pg', group: :production # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'mini_racer', platforms: :ruby gem 'bcrypt' gem 'carrierwave' gem 'pry-rails' gem 'rmagick', '2.16.0' # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use ActiveStorage variant gem 'mini_magick', '~> 4.8' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'better_errors' # デバッグ用gem gem 'pry-byebug' gem 'pry-doc' gem 'pry-rails' end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :production do gem 'fog', '1.42' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of chromedriver to run system tests with Chrome gem 'chromedriver-helper' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

試したこと

postgresqlをインストールすると解決すると書いてあるサイトがあったため、
sudo yum install postgresql-devel
コマンドを実行したあとで、再びbundle installを実行しましたが解決しませんでした。
回答いただけると幸いです…!!

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

エラーメッセージに記載されている

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

のとおりではないでしょうか?

PostgreSQL のバージョンが古い。

古いバージョンの gem を使うか PostgreSQL を 9.2 以上のバージョンにアップグレードする必要がある。


お使いの CentOS のバージョンや PostgreSQL のバージョン等が不明なので具体的に記載はできませんが、PostgreSQL のソースコードをコンパイルしてインストールするか yumでPostgreSQLをインストールしてみよう の手順で、 PostgreSQL 公式の Yum リポジトリから、新しいバージョンの PostgreSQL をインストールしてください。(URLは約10年前の記事なので、記載されているバージョンが、8.x と古いので、インストールする際は、新しいバージョンに読み替えてください。)

現時点でサポートされているバージョンは、リリースアナウンス( PostgreSQL 11.2, 10.7, 9.6.12, 9.5.16, and 9.4.21 Released! )にあるとおり、9.4 以降がアップデートされています。(サポート予定は、9.4.x は、2020年2月まで、9.6.x は、2021年11月まで、アップデートされる予定になっています。)
要件の詳細が不明なのではっきりとは言えませんが、今から新規インストールするのであれば、10.5 で問題のではないでしょうか。

投稿2019/05/07 00:01

編集2019/05/07 00:12
CHERRY

総合スコア25171

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

TOMSOYA

2019/05/07 00:10

CHERRYさん回答ありがとうございます! 早速試してみたいと思います! ちなみにCentOSは6.10、PostgreSQLは8.4.20でした。
CHERRY

2019/05/07 00:15

回答直前に追記した内容が記載されていなかったので、再度保存しなおしました。 さすがに PostgreSQL の 8.4 は、10年前のバージョンなので、ちょっとふるいですね... CentOS 6 であれば、 https://qiita.com/hatayan1126/items/9b0d3be9c7ecdc207642 を参考にして、PostgreSQL 9.6.x をインストールするほうが良いのかもしれません。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問