3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gem install pg が上手くいかない時の対処法

Last updated at Posted at 2020-02-11

##開発環境

ubuntu(wsl)
Ruby 2.5
Rails 5.2

##エラー内容
bin/rails db:createを実行すると

Could not find gem 'pg (>= 0.18, < 2.0)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

言われてた通りbundle installを実行すると、

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.

gem install pg -v 1.2.2を確認しろとのことなので、gem install pg -v 1.2.2を実行する。

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/username/.rbenv/versions/2.5.1/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/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/pg-1.2.2 for inspection.
Results logged to /home/username/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.2.2/gem_make.out

##解決策
下記のコマンドを実行して、その後gem install pg -v 1.2.2をする。

sudo apt install libpq-dev

###参考文献

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?