installing ruby-pg gem – handling extconf.rb:1:in `require‘: no such file to load — mkmf (LoadError)

Diagnosis: Installing ruby-pg fails when trying to create the native extensions:

florian@PC172:~$ sudo gem install ruby-pg
Building native extensions. This could take a while...
ERROR: Error installing ruby-pg:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb install ruby-pg
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

Gem files will remain installed in /var/lib/gems/1.8/gems/ruby-pg- for inspection.
Results logged to /var/lib/gems/1.8/gems/ruby-pg-

Medicine: install the ruby-dev package – as recommended on RubyForge and on Mentalized by Jakob Skjerning. In some cases, the xxx-dev packages are required for building the native extensions, too- e.g. libsqlite3-dev to install the sqlite3-ruby gem.