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

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

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

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

1108閲覧

pgがインストールできません。

chizuru.

総合スコア2

Ruby on Rails

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

1クリップ

投稿2020/04/24 12:06

編集2020/04/24 12:22

前提・実現したいこと

AWSでHPを作成し、Herokuにデプロイ致しました。
言語はRuby on Rails です。
pgをインストールしたいのですがErrorが出てしまいインストールができません。

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

現在のError状況

Using rake 13.0.1 Using concurrent-ruby 1.1.6 Using i18n 1.8.2 Using minitest 5.14.0 Using thread_safe 0.3.6 Using tzinfo 1.2.7 Using activesupport 5.2.4.2 Using builder 3.2.4 Using erubi 1.9.0 Using mini_portile2 2.4.0 Using nokogiri 1.10.9 Using rails-dom-testing 2.0.3 Using crass 1.0.6 Using loofah 2.4.0 Using rails-html-sanitizer 1.3.0 Using actionview 5.2.4.2 Using rack 2.2.2 Using rack-test 1.1.0 Using actionpack 5.2.4.2 Using nio4r 2.5.2 Using websocket-extensions 0.1.4 Using websocket-driver 0.7.1 Using actioncable 5.2.4.2 Using globalid 0.4.2 Using activejob 5.2.4.2 Using mini_mime 1.0.2 Using mail 2.7.1 Using actionmailer 5.2.4.2 Using activemodel 5.2.4.2 Using arel 9.0.0 Using activerecord 5.2.4.2 Using mimemagic 0.3.4 Using marcel 0.3.3 Using activestorage 5.2.4.2 Using public_suffix 4.0.3 Using addressable 2.7.0 Using io-like 0.3.1 Using archive-zip 0.12.0 Using bcrypt 3.1.13 Using bindex 0.8.1 Using msgpack 1.3.3 Using bootsnap 1.4.6 Using bundler 1.17.3 Using byebug 11.1.1 Using regexp_parser 1.7.0 Using xpath 3.2.0 Using capybara 3.32.0 Using mini_magick 4.10.1 Using ffi 1.12.2 Using ruby-vips 2.0.17 Using image_processing 1.10.3 Using carrierwave 2.1.0 Using childprocess 3.0.0 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 1.0.0 Using thor 1.0.1 Using railties 5.2.4.2 Using coffee-rails 4.2.2 Using orm_adapter 0.5.0 Using responders 3.0.0 Using warden 1.2.8 Using devise 4.7.1 Using jbuilder 2.10.0 Using kaminari-core 1.2.0 Using kaminari-actionview 1.2.0 Using kaminari-activerecord 1.2.0 Using kaminari 1.2.0 Using rb-fsevent 0.10.3 Using rb-inotify 0.10.1 Using ruby_dep 1.5.0 Using listen 3.1.5 Using mysql2 0.5.3 Fetching pg 0.20.0 Installing pg 0.20.0 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /home/ec2-user/.rvm/gems/ruby-2.5.1/gems/pg-0.20.0/ext /home/ec2-user/.rvm/rubies/ruby-2.5.1/bin/ruby -I /home/ec2-user/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0 -r ./siteconf20200424-10994-5s6ew9.rb extconf.rb --with-pg-config\=/usr/pgsql-9.3/bin/pg_config Using config values from /usr/pgsql-9.3/bin/pg_config sh: /usr/pgsql-9.3/bin/pg_config: No such file or directory sh: /usr/pgsql-9.3/bin/pg_config: No such file or directory 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=/home/ec2-user/.rvm/rubies/ruby-2.5.1/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-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: /home/ec2-user/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/pg-0.20.0/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/ec2-user/.rvm/gems/ruby-2.5.1/gems/pg-0.20.0 for inspection. Results logged to /home/ec2-user/.rvm/gems/ruby-2.5.1/extensions/x86_64-linux/2.5.0/pg-0.20.0/gem_make.out An error occurred while installing pg (0.20.0), and Bundler cannot continue. Make sure that `gem install pg -v '0.20.0' --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.5.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.1' # Use mysql as the database for Active Record #gem 'mysql2', '>= 0.4.4', '< 0.6.0' # 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 # 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 'mysql2', '>= 0.4.4', '< 0.6.0' end group :production do gem 'pg', '0.20.0' gem 'rails_12factor' 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 :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] gem 'mini_magick' gem 'carrierwave' gem 'kaminari' gem 'devise' gem 'image_processing'

試したこと

始めにbundle installした際のError内容に

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

と表記がありましたので、
$ bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config
$ bundle install
を実行した結果現在のError状況となっております。

###補足情報(FW/ツールのバージョンなど)

初心者なのでいただいたご回答の専門用語がわからず、お返事が遅くなるか伺う可能性がございます。
申し訳ございません。
宜しければご教授お願い致します。

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

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

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

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

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

no1knows

2020/04/25 02:15

そもそも開発環境で期待通りに動作しているという認識で良いでしょうか?
chizuru.

2020/04/25 04:17

開発環境、テスト環境では期待通りに動作しております。
no1knows

2020/04/25 13:14 編集

解決していたので、参考までに。 そもそもですが開発環境と本番環境は揃えておくほうが良いです。 データベースの違いでエラーが出てくることも多いので。 開発環境がMySQLであれば、本番環境もMySQLとするのが一般的な開発方法になるかと思います。 なのでChizuru.さんの状況を踏まえると、もしMySQLで開発しているのなら、「HerokuでMySQLを利用してデプロイする方法」というのが適した回答になるかと思います。 ただ提示された質問への回答だと、回答いただいた内容が適した回答ですね。
chizuru.

2020/04/25 15:18

ご教授ありがたいです(>_<) 勉強不足でだいぶ詰まっております。 環境構築をしっかりとお勉強して 出直して参ります。 また質問に来ると思いますので その時は良ければ宜しくお願い致します。
guest

回答1

0

ベストアンサー

Make sure that gem install pg -v '0.20.0' --source 'https://rubygems.org/' succeeds before bundling.

とエラーの最後の方にあるので、
gem install pg -v '0.20.0' --source 'https://rubygems.org/'
をコマンドで実行したら、細かいエラーが表示されませんか?

投稿2020/04/25 08:01

danknowhow

総合スコア7

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

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

chizuru.

2020/04/25 08:30

ご回答ありがとうございます!!! ご教授頂いたコマンドを実行してみましたら Successfully installed pg-0.20.0 Parsing documentation for pg-0.20.0 Done installing documentation for pg after 0 seconds 1 gem installed と出てきたのでbundle installしてみましたらできました!!! ありがとうございました!!!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問