Installing Ruby on Rails and PostgreSQL on OS X, Second Edition
51 comments Latest by Clifford Heath Wed, 13 May 2009 00:23:12 GMT
It’s been just over a year since I posted the article, Install Ruby, Rails, and PostgreSQL on OSX and it still gets quite a bit of traffic. Unfortunately, there have been a few changes in the install process that have caught people.
Today, I am leaving my PowerBook G4. It’s being replaced with a MacBook because the logic board is on the fritz. So, guess what that means? I get to install Ruby, Ruby on Rails, PostgreSQL on OS X again! I figured that I would post a revised version of my previous article for those who may go through this same process in the near future.
Step Zero: Install iTerm (optional)
You’ll spend a lot of time in your terminal as a Rails developer. I’m not a big fan of Terminal.app as it lacks tabbed windows1 and you’ll often find me with around ten tabs open. I’ve been using iTerm for a few years and it’s definitely improved in the past year and doesn’t seem to crash nearly as often as it used to.
Once installed, I always change the default color scheme as I prefer the white on black schema. The menus in iTerm are lacking some thoughtful interaction design, but I’ve figured out the right way to do it (after a long time of stumbling on it by accident). In iTerm, you’ll want to edit the Default bookmark, which you can access by going to Manage Bookmarks under the Bookmarks Menu.

Set the Display value to classic iTerm and you’re golden.
Now… let’s get to business…
Step 1: Install Xcode Tools
Without installing Xcode tools from Apple, we’re not going to get very far. First, you’ll need to grab a copy of Xcode, which you can download on Apple’s Developer Connection site. It’s almost a 1GB download, so you’ll want to start your download and use your multi-tasking skills and grab a Viso, read some blog posts.
- Download Xcode (dmg)
I’m going to make the assumption here that you know how to install a dmg on osx. Once this is installed, you can move on to the next step!
Step 2: All Your MacPorts are Belong to Us
MacPorts (formerly known as DarwinPorts) is a package management system for OS X. This is what we’ll use to install most of the necessary programs to develop and run your Ruby on Rails applications. If you’re from the Linux or BSD world, you are likely familiar with similar tools… such as: apt-get, port, and yum.
You’ll want to download MacPorts and install the dmg file.

Now that this is installed, we should test it.
With a new terminal, run the following:
$ port version
Version: 1.442
Success! Let’s get going…
Step 3: Installing the Ruby on Rails development stack
We’re going to go through a series of small steps, which may take some time depending on how fast your internet connection and computer is.
Install Ruby and RubyGems
In order to install Ruby, we’re going to use MacPorts with the port command, which is now available for installing various packages on our OS X machines.
$ sudo port install ruby rb-rubygems
It’ll probably take a while to download and install Ruby and all of it’s known dependencies. In the meantime, check out some funny code. KTHXBYE!
Still waiting for it to install, perhaps you could do something like… begin writing a comment on this post, writing your own blog post, watch a funny video, or recommend me. I walked to Backspace with Gary to get an Americano… and it’s still not done. :-p
(minutes/hours/weeks later)
Okay… I trust that it finished installing Ruby and RubyGems without any hiccups. Let’s test them from our terminal to make sure.
Let’s check the version…
$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
Now, let’s make sure that Ruby is working properly…
$ irb
irb(main):001:0> x = 1
=> 1
irb(main):002:0> puts "wee!!!" if x == 1
wee!!!
Great, we’re on a roll. Let’s get the rest of the stack installed.
Install Ruby on Rails
We’re going to install Ruby on Rails with the gem command that installing RubyGems provided.
$ sudo gem install -y rails
This command should produce an output similar to the following.
Successfully installed rails-1.2.3
Successfully installed rake-0.7.3
Successfully installed activesupport-1.4.2
Successfully installed activerecord-1.15.3
Successfully installed actionpack-1.13.3
Successfully installed actionmailer-1.3.3
Successfully installed actionwebservice-1.2.3
Installing ri documentation for rake-0.7.3...
Installing ri documentation for activesupport-1.4.2...
Installing ri documentation for activerecord-1.15.3...
Installing ri documentation for actionpack-1.13.3...
Installing ri documentation for actionmailer-1.3.3...
Installing ri documentation for actionwebservice-1.2.3...
Installing RDoc documentation for rake-0.7.3...
Installing RDoc documentation for activesupport-1.4.2...
Installing RDoc documentation for activerecord-1.15.3...
Installing RDoc documentation for actionpack-1.13.3...
Installing RDoc documentation for actionmailer-1.3.3...
Installing RDoc documentation for actionwebservice-1.2.3...
Install Rails-friendly gems
Mongrel
If you’re developing with Rails, it’s highly recommended that you use install and use Mongrel for your development and production environments. The following command will install the mongrel and mongrel_cluster gems (including their dependencies).
$ sudo gem install -y mongrel mongrel_cluster
* Note: Be sure to select the proper platform for mongrel. (hint: OS X is NOT mswin32)
My terminal output:
$ sudo gem install -y mongrel mongrel_cluster
Password:
Bulk updating Gem source index for: http://gems.rubyforge.org
Select which gem to install for your platform (i686-darwin8.9.1)
1. mongrel 1.0.1 (mswin32)
2. mongrel 1.0.1 (ruby)
3. mongrel 1.0 (mswin32)
4. mongrel 1.0 (ruby)
5. Skip this gem
6. Cancel installation
> 2
Select which gem to install for your platform (i686-darwin8.9.1)
1. fastthread 1.0 (ruby)
2. fastthread 1.0 (mswin32)
3. fastthread 0.6.4.1 (mswin32)
4. fastthread 0.6.4.1 (ruby)
5. Skip this gem
6. Cancel installation
> 1
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed mongrel-1.0.1
Successfully installed daemons-1.0.6
Successfully installed fastthread-1.0
Successfully installed gem_plugin-0.2.2
Successfully installed cgi_multipart_eof_fix-2.1
Installing ri documentation for mongrel-1.0.1...
Installing ri documentation for daemons-1.0.6...
Installing ri documentation for gem_plugin-0.2.2...
Installing ri documentation for cgi_multipart_eof_fix-2.1...
Installing RDoc documentation for mongrel-1.0.1...
Installing RDoc documentation for daemons-1.0.6...
Installing RDoc documentation for gem_plugin-0.2.2...
Installing RDoc documentation for cgi_multipart_eof_fix-2.1...
Successfully installed mongrel_cluster-0.2.1
Step 4: Installing the World’s Most Advanced Database Server… PostgreSQL!
At PLANET ARGON, we develop our applications on top of PostgreSQL. I’ve long been advocating the adoption of this awesome open source database in the Rails community. Just over a year ago, Jeremy Voorhis (PLANET ARGON alumnus) and I were interviewed on the Ruby on Rails podcast and had the opportunity to discuss our preference of PostgreSQL over the alternatives (mysql, sqlite, firebird, etc.).
We’re going to install PostgreSQL 8.2 from MacPorts by running the following command.
$ sudo port install postgresql82 postgresql82-server
While this is installing, you might take a moment to check out some space shuttles.
Setting up PostgreSQL
You may have noticed the output of the previous port installation of PostgreSQL 8.2, suggested that you do the following. Let’s do that now…
$ sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb
$ sudo su postgres -c '/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb'
Have PostgreSQL start automatically on system start-ups
Unless you’re concerned about extra applications running in the background, I’d encourage you to add PostgreSQL to launchd, which will start it automatically after system reboots.
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql82-server.plist
Adding PostgreSQL commands to your $PATH
For some reason, MacPorts doesn’t add the PostgreSQL programs to the default bash PATH, which means that you can’t run psql, pg_dump, or createdb/dropdb without specifying the full path to where they were installed. What we’ll do is add them to our default terminal profile.
sudo vi /etc/profile (you can use mate, emacs, joe or any other preferred editor to do this)
This file gets loaded every time a new terminal session is started.
Let’s add /opt/local/lib/postgresql82/bin to the end of the value for PATH.
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/lib/postgresql82/bin"
Save the file and then open a new terminal. To test this, you should get the following output when you run which psql.
$ which psql
/opt/local/lib/postgresql82/bin/psql
Creating a new PostgreSQL user
When I’m working on Rails applications in my development environment, I really don’t want to have to specify a username and password in every config/database.yml file for each of our ongoing client projects. When PostgreSQL was installed, it created a superuser named postgres, which is great, but I’d like one that matches my system username, so that I’m not prompted at all for a username or password to connect to PostgreSQL.
To do this, we’ll use the createuser command, which comes with PostgreSQL. As you can see, I’m creating a new user with superuser privileges (and will hopefully be the last time I have to do a -U postgres).
$ createuser --superuser robbyrussell -U postgres
CREATE ROLE
Let’s take a quick moment to test this out.
# create a new database
$ createdb my_test_db
CREATE DATABASE
# drop the database
$ dropdb my_test_db
DROP DATABASE
Great, everything looks good here.
We now have a running installation of PostgreSQL with a new user account. All we need to do now is install the appropriate RubyGem to allow our Ruby applications to connect to it.
Installing the Ruby Postgres gem
UPDATE: Hydro posted a commented, which lead me to the ruby-postgres gem.
You can install ruby-postgres gem by running the following command.
$ sudo gem install -y ruby-postgres
Let’s take a moment to test that this installed properly.
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'postgres'
=> true
If this returns true, than we should be good to go. We’ve now built a professional development environment for working with Ruby on Rails. Doesn’t that feel great?
Test your install
You can look back at my older post to walk through the process of testing out your setup with a new Rails application.
Closing thoughts
I hope that this post has been useful for you. It took me a few hours to walk through this process and it’s how all of our designers and developers at PLANET ARGON installs and configures their development environment.
We also install the following programs on new machines.
- TextMate
- Subversion:
sudo port install subversion - RSpec:
sudo gem install -y rspec - ...amongst other gems that are needed on specific projects
Until next time… have fun!
1 Rumor: Mac OS X Leopard will give Terminal.app tabs! (see screenshot)
Enjoying the content? Be sure to subscribe to my RSS feed.






Thanks Robby for your post. Some of us have been looking forward to your comments (since you are a PostgreSQL – Ruby guru) about exactly which version of ruby-postgres to use (since there is confusion in the market and different Ruby PostgreSQL adapters are starting to emerge such as Jeff Davis’ fork called “ruby-pg” and older ones are not totally deprecated such as postgres-pr).
What I don’t understand with your instructions is why won’t this work for you? It works for me (and I’m also using MacPorts):
$ sudo gem install -y ruby-postgres
Hydro,
I hadn’t seen the ruby-postgres gem before. I was only aware of the postgres (pure C) and postgres-rb gems.
Robby,
Thanks for the note about postgres (pure C) gem because I didn’t know about it. I learned about the ruby-postgres gem from the 2nd Edition of the Rails Book (Agile Web Development with Rails) which states verbatim on page 293:
—-—-—-—-—-—-—-—-—-——
Postgres Adapter
Requires: The ruby-postgres gem, installed using
depot> gem install ruby-postgres
—-—-—-—-—-—-—-—-—-——
Considering your knowledge and expertise using Rails with PostgreSQL, I think I will try to use the pure C gem instead of the older ruby-postgres gem (which seems to have been last updated a few years ago).
Thanks dude!
Robby,
Just did some more investigation. I think the postgres and ruby-postgres gem might be the same beast, no? Check this out …
1.) Get a list of gems relating to databases for Ruby here:
http://rubyforge.org/softwaremap/trove_list.php?form_cat=66
2.) URL above returns a page that includes “postgres” (#13). Click on “postgres” and get (notice the URL contains the name “ruby-postgres” at the end of the URL:
http://rubyforge.org/projects/ruby-postgres/
3.) The page returned from the URL in #2 above now has this content:
postgres 2006-04-06 Snapshot April 6, 2006 – Download
Click Download and get this URL:
http://rubyforge.org/frs/?group_id=636&release_id=4809
4.) The page returned by the URL in #3 above yields:
2006-04-06 Snapshot 2006-04-06 13:32
ruby-postgres-0.7.1.2006.04.06.gem 46 KB 772 Any .gem (RubyGem)
5.) So what gives? Is the “ruby-postgres” gem the same as the merely “postgres” gem? Do we have a namespace confusion issue? It would be great to avoid namespace confusion if at all possible.
Cheers,
Hydro
Sweet! I just ordered a new MacBook Pro from Apple yesterday so that I could learn Ruby on Rails over the summer. This article has great timing. =)
Robby,
I think you should take a second look at your instructions and consider using the ruby-postgres gem instead of just “postgres” because as best I can tell (and I just went through the steps again to test it myself), you can save yourself trouble by merely doing:
$ sudo gem install -y ruby-postgres
I am nearly certain that the source of “ruby-postgres” is the same as that of “postgres” but for some reason “ruby-postgres” installs with no need for a workaround.
From my machine (Intel iMac running OS X 10.4.9) check it out:
-
$ sudo gem install -y ruby-postgres
Select which gem to install for your platform (i686-darwin8.9.1)
> 1
Building native extensions. This could take a while…
Successfully installed ruby-postgres-0.7.1.2006.04.06
Installing ri documentation for ruby-postgres-0.7.1.2006.04.06…
Installing RDoc documentation for ruby-postgres-0.7.1.2006.04.06…
-
$cd /opt/local/lib/ruby/gems/1.8/gems
$ls -p | grep postgres
ruby-postgres-0.7.1.2006.04.06/
$ cd ruby-postgres-0.7.1.2006.04.06
$ ls -altr
rw-r-r— 1 root admin 1562 Jun 19 16:23 type-oids.h
drwxr-xr-x 3 root admin 102 Jun 19 16:23 tests/
drwxr-xr-x 8 root admin 272 Jun 19 16:23 sample/
rw-r-r— 1 root admin 1119 Jun 19 16:23 ruby-postgres.gemspec
rw-r-r— 1 root admin 66822 Jun 19 16:23 postgres.c
rw-r-r— 1 root admin 6102 Jun 19 16:23 libpq-compat.c
rw-r-r— 1 root admin 941 Jun 19 16:23 extconf.rb
drwxr-xr-x 4 root admin 136 Jun 19 16:23 doc/
rw-r-r— 1 root admin 4347 Jun 19 16:23 README.ja
rw-r-r— 1 root admin 2980 Jun 19 16:23 README
rw-r-r— 1 root admin 198 Jun 19 16:23 MANIFEST
rw-r-r— 1 root admin 875 Jun 19 16:23 Contributors
rw-r-r— 1 root admin 6082 Jun 19 16:23 ChangeLog
drwxr-xr-x 8 root admin 272 Jun 19 16:23 ../
rw-r-r— 1 root admin 8279 Jun 19 16:23 mkmf.log
rw-r-r— 1 root admin 4324 Jun 19 16:23 Makefile
rw-r-r— 1 root admin 43332 Jun 19 16:23 postgres.o
-rwxr-xr-x 1 root admin 40160 Jun 19 16:23 postgres.bundle
drwxr-xr-x 19 root admin 646 Jun 19 16:23 ./
-
Welcome to Darwin!
iMac:~ me$ irb
irb(main):001:0> require ‘rubygems’
=> true
irb(main):002:0> require ‘postgres’
=> true
-
I have yet to test it out with a fresh Rails app against a fresh install of PostgreSQL 8.1.9 from MacPorts but that’s next. All indications are, from the above, that we’re talking about the same C-based gem (ruby-postgres == postgres) and that using the name “postgres” in the gem install process causes the need for a work around but using the name “ruby-postgres” does not.
Wow! That’s eerily similar to a post I wrote a few weeks ago: http://rid.onkulo.us/archives/18-installing-ruby-on-rails-on-mac-os-x
Wow! That’s eerily similar to a post I wrote a few weeks ago: http://rid.onkulo.us/archives/18-installing-ruby-on-rails-on-mac-os-x
From what I understand, ‘ruby-postgres’ is the updated version of the ‘postgres’ library and is the one to use.
The ‘pg-ruby’ library doesn’t look like it’s had any activity.
Michael Air wrote:
-
From what I understand, ‘ruby-postgres’ is the updated version of the ‘postgres’ library and is the one to use.
The ‘pg-ruby’ library doesn’t look like it’s had any activity.
-
Thanks Michael. If what you assert is true, then tsk tsk to Robby on Rails for not being aware of this and thus posting unnecessary workarounds!
Robby wrote:
“I hadn’t seen the ruby-postgres gem before. I was only aware of the postgres (pure C) and postgres-rb gems.”
Robby just keeping you on your toes ;-)
robby, if you use rubygems from port, why didn’t you encourage to use rails and other gems from port as well?
Sorry, I’m just curious as I always build my rubygems from source (ruby setup.rb) not port.
Postgresql question: how do you guys do high availability with postgres? I hear it’s a lot easier with mysql.
I believe the postgres cli tools aren’t in bin for avoiding name clashes (having, say, postgres74 and 82 installed at the same time), if you noticed, there is symlink psql82 available, if you don’t need the rest.
Also even if you don’t need workarounds with ruby-postgres, if you ever have gem that can’t find libs, you can also do
But great writeup!
Thanks for the great update on a classic post, Robby. I don’t know about others, but one thing I’d love to know more about is how to properly use PostgreSQL’s constraints in tandem with Rails model validations. You know, kind of a ‘defense in depth’ approach. There seems to be precious little documentation about this. For example, every time I try to give my DB the power to enforce data integrity (with or without model validation), when it trips up, I don’t know how to rescue the exception in Ruby if it’s a PostgreSQL exception, rather than a AR exception. Maybe I’m just missing something and need to put on the Rails white belt once again… oh wait, I’m still wearing it ;)
Thanks man. The day after we use your blog to install Postgres :-)
Yes, we have come over to the dark site ;-)
Seriously, thanks for the blogumentation.
-Joe
Stephen, yeah same here. That would be a great article—how to leverage postgresql’s strength in Rails apps.
Thanks for the tutorial. Actually didn’t need the Postgresql part, though I realize it’s why everyone reads it.
From our perspective as publishers of legacy/mainframe integration software, I’m wondering whether it might be worth it to add Ruby on Rails support. Right now, we support Java and .NET.
Legacy integration certainly isn’t considered cool, though it’s clearly relevant to the “enterprise”.
@hydro:
Thanks for providing the information about the
ruby-postgresgem. I’ve updated the article to use this approach.@ariekeren:
Because the ports aren’t up to date. Look at the version of Rails you referenced. We’re on 1.2.3 via rubygems. In fact, I would discourage using any package management tool for ruby gems… except rubygems.
Just a quick note that I had to do a
before installing ruby, as I got this error:
Thanks It’s a really good guide.
Thanks It’s a really good guide.
Thanks for the guide. It works great. I was wondering if you’ve tried to get PostgreSQL up and running on Leopard. I’m doing some other development in the seed and would like to be able to move some of my RoR projects over to 10.5 as well, but every approach to install PostgreSQL I’ve tried has failed. Have you tried/had any luck?
Feel free to contact me offline.
Cheers for the guide. I’ve followed it through but I encounter problems at the end!
Once I’ve installed Postgres, this bit goes ok;
—-—-—-—-—-- $ sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb $ sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb $ sudo su postgres -c ’/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb’ —-—-—-—-—-—-—-
and ‘whichpsql’ returns the correct string.
Then, when I try and create myself as a superuser I get
—-—-—-—-—-—-—— createuser: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket ”/tmp/.s.PGSQL.5432”? —-—-—-—-—-—-——
Any ideas? I’ve been messing around for a while now and I’m pretty flummoxed!
If I’ve done something foolishly wrong and it’s obvious, please ridicule me!
Cracking tutorial, even better that it also includes Postgres.
Thanks Robby.
@Chris – It looks like you haven’t started Postgres. You’ll probably find it works when you reboot, but if like me you don’t start Postgres on boot, then try this:
sudo /opt/local/etc/LaunchDaemons/org.macports.postgresql82-server/postgresql82-server.wrapper start
Hi
Thanks ! ! !
It’s a really good guide!
When I execute: sudo gem install -y rails
I receive this message: sudo gem install -y rails Password: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’: no such file to load—sources (LoadError) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require’ from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/source_info_cache.rb:6 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’ from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require’ from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:12 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’ from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require’ from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:112:in `manage_gems’ from /opt/local/bin/gem:10
Why?
Thank you.
Bobby and everyone,
thanks for your tutorial and your advices. But – I’ve got a problem.. ruby-postgres doesn’t install..
This is what happens:
clxxii:~ j82018$ sudo gem install -y ruby-postgres Password: Select which gem to install for your platform (universal-darwin8.0) 1. ruby-postgres 0.7.1.2006.04.06 (ruby) 2. ruby-postgres 0.7.1.2006.04.06 (mswin32) 3. ruby-postgres 0.7.1.2006.04.05 (mswin32) 4. ruby-postgres 0.7.1.2006.04.05 (ruby) 5. Skip this gem 6. Cancel installation > 1 Building native extensions. This could take a while… ERROR: While executing gem … (Gem::Installer::ExtensionBuildError) ERROR: Failed to build gem native extension.
ruby extconf.rb install -y ruby-postgres checking for main() in -lpq… noProvided configuration options: —with-opt-dir —without-opt-dir —with-opt-include —without-opt-include=${opt-dir}/include —with-opt-lib —without-opt-lib=${opt-dir}/lib —with-make-prog —without-make-prog —srcdir=. —curdir —ruby=/usr/local/bin/ruby —with-pgsql-dir —without-pgsql-dir —with-pgsql-include —without-pgsql-include=${pgsql-dir}/include —with-pgsql-lib —without-pgsql-lib=${pgsql-dir}/lib —with-pqlib —without-pqlib Could not find PostgreSQL build environment (libraries & headers): Makefile not created
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06 for inspection. Results logged to /usr/local/lib/ruby/gems/1.8/gems/ruby-postgres-0.7.1.2006.04.06/gem_make.out clxxii:~ j82018$
...could anyone please say what I should do? thanks for help!
@Tuomas
I’m getting the same error. I’ve done this whole install a couple of times now, but for some reason I’m getting the error now.
What version of postgresql are you running and what OS?
I’m on debian and postgres 1.8
Hi Robby,
Thanks for this tutorial! I ran into a problem with postgres not installing properly (the no such file to load problem). I just updated my ruby installation and it worked great!
Jordan
Can you comment on the available replication options for PG?
failed here… and i don’t know what to do anymore…
macs-computer:~ bernard$ sudo gem install -y ruby-postgres Select which gem to install for your platform (universal-darwin8.0) 1. ruby-postgres 0.7.1.2006.04.06 (ruby) 2. ruby-postgres 0.7.1.2006.04.06 (mswin32) 3. ruby-postgres 0.7.1.2006.04.05 (mswin32) 4. ruby-postgres 0.7.1.2006.04.05 (ruby) 5. Skip this gem 6. Cancel installation > 1 Building native extensions. This could take a while… ERROR: While executing gem … (Gem::Installer::ExtensionBuildError) ERROR: Failed to build gem native extension.
ruby extconf.rb install -y ruby-postgres extconf.rb:6: command not found: pg_config—includedir extconf.rb:13: command not found: pg_config—libdir checking for main() in -lpq… noI had the same problem.
extconf.rb is using ENV[“POSTGRES_INCLUDE”] and ENV[“POSTGRES_LIB”]. So if you define those in your environment, it should work.
I couldn’t install ruby-postgres either. I then figured that for some reason /opt/local/bin wasn’t in my path. This broke installing the gem as it was using the 1.8.2 version in /usr/bin instead. Once the path was in, everything worked fine.
I would add this to adding to the path in the main article as I needed to read the old one to figure what was different.
I couldn’t install ruby-postgres either. I then figured that for some reason /opt/local/bin wasn’t in my path. This broke installing the gem as it was using the 1.8.2 version in /usr/bin instead. Once the path was in, everything worked fine.
I would add this to adding to the path in the main article as I needed to read the old one to figure what was different.
I just wanted the postgres part, and that worked fine, until I tried to install pgsql_perl5-1.9.0. That thing said I needed the libpq.so file, but when I looked in the lib dir, I only saw libpq.a instead of the .so file. I’m installing on an Intel Mac running 10.4
Is there an easy way for me to create a libpq.so file?
Thanks mate . It worked perfect for me .
Alas, I too still have my trusty PowerBook G4, although mine is not on the fritz yet. However, it is showing it’s age with slowness. Right now I’m running Ruby/Rails/Mongrel inside of Locomotive and am noticing it’s quite slow. Would you know if installing it according to above would yield a faster set up? The lines blur to me between installing the “ruby” version of gems, yet it does a “Building native extensions.”, yet I have all the source to the gems installed and modifying them shows instant results. Thanks in advance for any ideas.
“Could not find PostgreSQL build environment (libraries & headers): Makefile not created”
I had this problem too, then I found that what was missing (on my Ubuntu 7.04 box) was the postgresql-server-dev-8.2 package from apt.
sudo apt-get install postgresql-server-dev-8.2
After that, ruby-postgres from gems installed without problems.
If you’re upgrading to Leopard, I’d suggest that you check out my new article, Using MacPorts Ruby and Rails after Upgrading to OS X Leopard. This will be helpful to any of you that installed Rails by following my guide.
I am trying a fresh install under Leopard. I’ve installed postgres from www.macupdate.com/info.php/id/8561/postgresql
Initially, I was having the same install error mentioned several times above regarding extconf.rb when installing either of the gems (ruby-postgres or postgres). I fixed this problem on ruby-postgres by defining the following two environment variables (as hinted above)...
export POSTGRES_INCLUDE=/Library/PostgreSQL8/include
export POSTGRES_LIB=/Library/PostgreSQL8/lib
However, the postgres gem still fails.
Was it ever determined which gem should be used?
Also, I now note that the ruby-postgres gem will STiLL install if I remove those lines from my .bashrc file. - strange -
sjf
There seems to be a lot of failures with the above method. There is a much easier way to install PostgreSQL on OS X Leopard without using the MacPort or compiling yourself – and one that maintains Apple’s established pathing conventions in OS X.
And if you want to use MySQL for RoR on Leopard, here is a great and simple guide.
Thank you so much!!
Thank you so much!!
That was helpful! Thanks ;)
I translate and adapt your guide to french : http://fabien.jakimowicz.com/articles/2008/05/09/rails-sur-postgresql-pour-leopard
I was experiencing the same problems with extconf.rb and pg_config:
“(...)extconf.rb:13: command not found: pg_config(...)”
Everything was solved after I install the package postgresql82-dev with fink.
I was experiencing the same problems with extconf.rb and pg_config:
“(...)extconf.rb:13: command not found: pg_config(...)”
Everything was solved after I install the package postgresql82-dev with fink.
ruby-pg is now the official postgres ruby gem: http://archives.postgresql.org/pgsql-interfaces/2007-12/msg00003.php
モンゴル語翻訳・通訳アウトソーシング業務を格安料金で請負います。 Mongolia IT companyweb and software development service Албан байгууллагын веб сайтыг түргэн шуурхай хийж үйлчилнэ. баннер, лого веб дизайнхийнэ モンゴルでオフショア開発している会社。 モンゴルウェブを格安料金で制作します。 Mugen Link is Mongolian Web Developer company. Монгол дах Япон хэл ний орчуулга хийдэг компани. モンゴル語の翻訳・通訳なら弊社へ。 モンゴル語ホームページを作成します。 Japanese guide in Mongolia Mongolie Informationen platzieren. Mongolia hotel guide. We provide all informations about Ulaanbaatar restaurant by this site. Mongolia nature information site. モンゴルニュースをこちらからゲットしましょう。 モンゴルレストランに関する情報サイト。 中央アジアモンゴルツアー情報サイト。
With postgresql83, the user postgres is added with no shell, so you get the error “su: /dev/null: Permission denied” when you try to create the default database. The solution is to add a shell to that user, using the Mac command: “sudo dscl . -create /Users/postgres UserShell /bin/sh”