In the effort to migrate my existing Rails app from Slicehost to Heroku, I encountered some MySQL – PostgreSQL compatibility issues, I’ll write a separate post on Heroku gotchas later. In order to debug those issues, I need to install PostgreSQL on my local Windows development machine. Did you think it’ll be trivial? Of course not, nothing open source is ever trivial on Windows…. nothing, trust me on that.
First thing first, install PostgreSQL (V8.4.2-1 as of this article’s date).
And silly me, first thing I tried was gem install postgres, not even close. A little research led me to this article to try gem install ruby-postgres. That seemed to work.
Next I tried to run rake db:create, if memory serves me correctly, I ran into this error
Can’t activate rubyforge (= 0.4.4, runtime), already activated rubyforge-1.0.0 (Gem::Exception)
To fix it, I followed the advice in this article.
From here onwards, I kept trying rake db:migrate and got several other errors for libpq.dll, libeay32.dll, ssleay32.dll, and a whole slew of other missing DLLs. According to this article, it said to
You need to go back to the postgres installer file and
copy a couple of libraries to the ruby “bin” file (for example in
Don’t overwrite any files if they already exist in the ruby directory !
I tried the advice without much success because I kept getting DLL errors like missing DLLs and like
ruby.exe – Ordinal Not Found
The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll.
The ordinal 2821 could not be located in the dynamic link library LIBEAY32.dll.
Bottom line, don’t try the advice from the above article, it is outdated and there are new DLLs added to PostgreSQL since then, restore ruby\bin to what it was if you did try. Then I came across this article saying to add C:\Program Files\PostgreSQL\8.4\bin to your Windows path which as it turns out, installing PostgreSQL didn’t do, why I have no freaking idea.
Anyway, after adding the path, I’m still getting the ordinal could not be located in the DLL errors for LIBEAY32.DLL and SSLEAY32.DLL. It turns out that those 2 DLLs support OpenSSL and my machine is littered with multiple copies of it from cygwin, Google, SVN, Ruby, Postgres, VMware, etc. It’s a freaking mess. I took a cue from from this posting and copied those 2 files from C:\Program Files\PostgreSQL\8.4\bin to C:\ruby\bin. First, rename those 2 files in C:\ruby\bin to something else just in case you need them for some other reason before you copied them from PostgreSQL.
The final thing you need to do is to change your database.yml file to something like this
And now run rake db:create and rake db:migrate and you should be good to go. I think I got a headache writing this post.