Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension ubuntu

While running bundle install i am getting the following error in 'pg' gem i changed the gem as sqlite then too am getting same error. This is my error message.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb 
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
    from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from extconf.rb:2:in `<main>'


Gem files will remain installed in /var/lib/gems/1.9.1/gems/pg-0.16.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/pg-0.16.0/ext/gem_make.out

An error occurred while installing pg (0.16.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.16.0'` succeeds before bundling.

I tried apt-get install libpg-dev gem install pg -v '0.16.0' nothing helps me

like image 759
Prabhakaran Avatar asked Aug 05 '13 17:08

Prabhakaran


3 Answers

You should have postgresql installed before you install pg gem.

sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql libpq-dev

If your sqlite is not working, it looks like there are some packages you might have missed.

sudo apt-get install libreadline-dev libssl-dev zlib1g-dev build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
like image 164
Vysakh Sreenivasan Avatar answered Oct 13 '22 01:10

Vysakh Sreenivasan


On Ubuntu 14.04 (and possibly every other Debian 7 based distro) this problem is caused by the absence of the Ruby development package. Thus the fix is simply to install it:

sudo apt-get install ruby1.9.1-dev
like image 21
Luís de Sousa Avatar answered Oct 13 '22 00:10

Luís de Sousa


I have the same problem i solved it by installing it in ubuntu as normal user not as root user. I hope this may help you.

like image 25
chiyango Avatar answered Oct 13 '22 01:10

chiyango