Rails gem pg install failed - Lessons Learned 6

I created new Rails 7 app using Bootstrap

$rails new stockapp -c bootstrap -j esbuild

$cd stockapp/

$./bin/dev

The application worked as expected.

Then I added pg gem to Gemfile

$bundle install

However, it used to fail to install gem pg and I was getting error

Installing pg 1.4.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

 

I solved this by running following command

$sudo apt-get install libpq-dev

$bundle install

Rating: