Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo gem install pg won't work

I'm trying to get Rails to work with PostgreSQL. Apparently one thing I need to do along the way is sudo gem install pg. When I do that, I get this:

jason@buster:~/projects$ sudo gem install pg
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

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


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

I've Googled and tried a few things based on what I've found but nothing seems to help. Any advice? I'm on Ubuntu.

like image 675
Jason Swett Avatar asked Dec 30 '10 16:12

Jason Swett


2 Answers

You need to install your distro ruby-dev (or devel) package otherwise you won~t be able to build any ruby C extensions.

I'm not on ubuntu, but you package-manager command might be somewhat like this:

$ sudo apt-get install ruby-dev build-essential
like image 167
Mereghost Avatar answered Oct 14 '22 01:10

Mereghost


On Ubuntu:

$ sudo apt-get install postgresql-client libpq5 libpq-dev
$ sudo gem install pg
like image 45
yfeldblum Avatar answered Oct 14 '22 02:10

yfeldblum