[RUBY] When I try to install gempg it says I don't have libpq-fe.h

I suffered from an error when executing the application creation command, so I will write down the solution as a memo for latecomers. If you want to get into the main subject right away, I recommend you to skip to the section'Installing libpq-fe.h'.

Development environment

windows 10 home ubuntu 20.04 LTS ruby 2.7.1 Rails 6.0.3

Problem Deep digging order

As a deep digging order of the problem

① App creation command
rails new (app name) -d pstgresql

At An error occurred during the installation of pg (1.2.3) and Bundler cannot continue. Before bundling, make sure that gem install pg -v '1.2.3' --source' https: // ruby gems.org /' is successful. I got the error.

(2) Try executing the instruction command of the error statement
gem install pg -v '1.2.3'

Then, you will be instructed to look at the log because it remains in mkmf.lpg stored somewhere.

③ Check the mkmf.lpg log

I found an error saying that libpq-fe.h was not found in the log contents. Since it is not possible to dig deeper any further, it is concluded that the true cause is that libpq-fe.h does not exist.

Install libpq-fe.h

Method ① (Method solved by the Lord)
sudo apt install libpq-dev

In addition to the procedure that the Lord has solved, I will also list the methods that may be solved in some cases. It may be just that, so please forgive me even if I don't solve it. By the way, the Lord couldn't solve it with this.

Method ②
Sudo apt-get install libpq-dev
Method ③
sudo install postgresql-devel
Method ④
sudo install postgresql

Confirmation of resolution

rails new (app name) -d pstgresql

Confirm that no error has occurred even if you execute. Judge that the problem has been resolved. In the case of the main, it was solved by method ①.

Finally

If you get to this article and just don't understand, ask for help in this article. Probably by that time, the Lord should have some knowledge, so I'm sure he can help.

Recommended Posts

When I try to install gempg it says I don't have libpq-fe.h
When I try to sign up with devise, it automatically redirects to root_path
I don't know, so I'm going to write a list (you don't have to read it)
[It takes 3 minutes] When I tried to install VS Code on Ubuntu 18.04, it was unexpectedly easy.
When I changed to M1 mac, bundle install became impossible
When I try to put centos in VMware, pane is dead
I get a Ruby version error when I try to start Rails.
Don't forget to release it when you get the object from S3!