12

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

3

9 Answers 9

14

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 
Sign up to request clarification or add additional context in comments.

7 Comments

For sqlite, did you install the dependencies? I will update the answer with dependencies
I am not sure about sqlite dependencies but for postgresql i installed everything and its working in command line. But i am unable to locate gem.
The dependencies I have given is not restricted to sqlite. It also includes packages other than sqlite. Try installing the packages I have given, it should work.
Its throwing same error. I tried most of the Stackoverflow answers.
you tried this one sudo aptitude install ruby1.9.1-dev and then reinstalling the gems?
|
9

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 

1 Comment

sudo yum install ruby-devel for CentOS (solved my issue)
4

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.

Comments

2

I solved it by follwing these steps

  1. Uninstalled ruby completely using sudo apt-get purge ruby*
  2. Then in removed curl sudo apt-get purge curl

Then i followed this link to install Ruby RVM and rails 4.0.0

Install Rails 4.0.0

Comments

1

Install

http://postgresapp.com/ 

then

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" 

then

bundle install 

Comments

1

Sometimes you need to update your Ruby library, run this code:

sudo gem update --system 

Comments

1

I had an issue with slightly different Ruby builds. The existing application's Gemfile.lock was created using ruby-1.9.3-p194 and my local ruby was ruby-1.9.3-p484. Switching to the proper ruby allowed for a successful bundle.

Comments

0

I had the same problem with CentOS 6.5.

  1. Created a new user
  2. Added this users to the sudoers file /etc/sudoers
  3. Install ruby-devel using yum -y install ruby-devel

Comments

0

On Debian, the pg install was failing to build native extensions because postgres wasn't installed.

I installed the postgres dependencies with:

$ apt-get install postgresql postgresql-client libpq-dev 

Then the pg gem built its dependencies just fine:

$ gem install pg -v '0.18.3' Building native extensions. This could take a while... Successfully installed pg-0.18.3 1 gem installed 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.