バージョンーーーーーーーーーー
ruby 2.5.7p206
Rails 5.2.4.1
gem 2.7.6.2
Bundler version 2.1.4
psql (PostgreSQL) 9.1.24
ーーーーーーーーーーーーーーー
これまで入力したコマンド(PostgreSQL)ーーーーーーーー
sudo apt-get install -y postgersql
sudo apt-get install -y libpq-dev
sudo -u postgres createuser --createdb vagrant
ーーーーーーーーーーーーーーーーーーーーーーーーーーー
railsアプリの開発準備をしています。
データベースをSQLiteではなくpostgresqlにしてアプリを新規作成したいと思っています。
Postgresqlを含め、ある程度基本的なインストールを済ませることができましたが、
scaffoldをgemに追加してbundleinstallすると以下のようなエラーが表示されます。
エラーの原因をお教えいただけますと幸いです。
エラーメッセージ
To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/vagrant/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.2.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/vagrant/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/pg-1.2.2 for inspection. Results logged to /home/vagrant/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.2.2/gem_make.out An error occurred while installing pg (1.2.2), and Bundler cannot continue. Make sure that `gem install pg -v '1.2.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: pg
mkmf.logを開きましたが、以下のような構文が連なっていました。
find_executable: checking for pg_config... -------------------- yes -------------------- find_header: checking for libpq-fe.h... -------------------- yes "gcc -o conftest -I/home/vagrant/.rbenv/versions/2.5.7/include/ruby-2.5.0/x86_64-linux -I/home/vagrant/.rbenv/versions/2.5.7/include/ruby-2.5.0/ruby/backward -I/home/vagrant/.rbenv/versions/2.5.7/includ e/ruby-2.5.0 -I. -I/usr/include/postgresql -I/home/vagrant/.rbenv/versions/2.5.7/include -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimpli cit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -fPIC conftest.c -L. -L/home/vagrant/.rbenv/versions/2.5.7/lib -Wl,-rpath,/home/vagrant/.rbe nv/versions/2.5.7/lib -L/usr/lib -Wl,-rpath,/usr/lib -L. -L/home/vagrant/.rbenv/versions/2.5.7/lib -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/home/vagrant/.rbenv/versions/2.5.7/lib -L/home/vagrant/.rbenv/versions/2.5.7/lib -lruby -lpthread -lrt -ldl -lcrypt -lm -lc" checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } /* end */
該当のソースコード
Gemfire
# Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0'
database.yml
# PostgreSQL. Versions 9.1 and up are supported. # # Install the pg driver: # gem install pg # On OS X with Homebrew: # gem install pg -- --with-pg-config=/usr/local/bin/pg_config # On OS X with MacPorts: # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # On Windows: # gem install pg # Choose the win32 build. # Install PostgreSQL and put its /bin directory on your path. # # Configure Using Gemfile # gem 'pg' # default: &default adapter: postgresql encoding: unicode # For details on connection pooling, see Rails configuration guide # http://guides.rubyonrails.org/configuring.html#database-pooling pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
試したこと
エラー文中にある
gem install pg -v '1.2.2'
を実行してみましたが、行頭が「>」となり、インストールなどの動きはありませんでした。
回答1件
あなたの回答
tips
プレビュー