I created new Rails 7 app using Bootstrap
$rails new stockapp -c bootstrap -j esbuild
The application worked as expected.
Then I added pg gem to Gemfile
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