Ubuntu Craziness

With the non-profit app I’m collaborating on, we’re using Ruby on Rails and Postgres. My development laptop is running Ubuntu 16.04, and last night, me and three experienced developers had a very difficult time getting Postgres up and running on my distro. I’m going to go through what we did, in case anyone reading this has the same troubles.

First, I ran the typical “sudo apt-get install postgresql” command. Everything installed normally and was successful. So, I bundled my app and proceeded to run “rake db:setup”.


It told me that it couldn’t initialize the database because of a peer authentication error. We had set a username and password in the database.yml file, but hadn’t set it up in my local database. So, we tried that. We created a user with the same password as in the yml file and re-ran the migration.


Ok, that didn’t work either. So, we thought, “How about we just change the user in the yml file to the default postgres user with no password?” So we did that.


Now we knew it wasn’t our migration file. Something was wrong with the postgres installation on my system. So, we started looking. The first thing we did was check to see if postgres was running. But, the system couldn’t find the postregql command. We soon realized that the directory the installation was looking for that should have held the postgresql script was missing. So we created it. Maybe that fixed the problem…


After a lot of searching and trial-and-error, we finally found that it was the default pg_hba.conf file. The authentication settings were set to hashes for the development environment. After setting these to “trust”, the database migrated, no problems.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s