I have a rails app that I am trying to run tests on. The day before I was able to run rake test:all
successfully and everything was in perfect order. Today, when I run rake test:all
I receive this error:
I know what this error means and know how to solve this error based on pg_hba.conf connections etc. etc. I've done it time and time again and have no problems with it.
However, I've found that the real underlying problem is that my Postgresql has been upgraded to 9.4 but my application requires 9.3. Running brew info postgresql
gives me the output shown below:
Basically, the output is saying that I need to upgrade to 9.4 and that 9.3 specific configurations are no longer updated (also shown below)
So now with the background info out of the way, this leads towards my real question. What is the 'correct' way to resolve this?
As a relatively new ruby/rails developer and programmer in general, I've always had someone to assist with installing my environment and have never really dove deep into the system installation layer and what happens under the hood. I know that I can't and shouldn't put this off any longer so after reading a few articles pertaining to the subject, this is what I've come across.
And a few stack overflow questions related to the subject.
What is the difference between all of these in relation to my Postgresql problem?
For example, based on the article from Homebrew, by running brew info postgresql, I can deduce that someone installed postgresql onto my Mac and somehow now I have 9.4 instead of 9.3 (despite to my knowledge never typing
brew update or upgrade`)
So does this mean PGSQL is installed on my MAC system? What about the Gemfile and Gemfile.lock?
According to the bundler documentation.....
Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.
Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install.
If that is the case, why isn't my bundle install resolving the discrepancy? Isn't the pg 0.18.1
supposed to install PGSQL for me? Why do I have to brew install postgresql and bundle install postgresql?
To make things even more confusing the bundler documentation states that in order to use bundler you have to execute gem install bundler
. What is this gem install
command, how is it different than the rest and why can't I brew install bundler
?
(I know that brew has no bundler formula to install, but theoretically why couldn't do this?)
Once again, in the 'Why you should use RVM and How to install Ruby on MAC', the guide states that RVM is used to install multiple versions of Ruby making it easy to switch around between versions, and to install gems I need to run gem install
. But why do I need to do this if bundle install does this for me? Why would I ever use bundle install if I can use gem install?
I know there's a lot of questions in this post, but an explanation would be great so I can understand what to do with this Postgresql problem I'm having. In my eyes, I either have to dump all my 9.3 data into 9.4 or somehow figure out how to downgrade back to 9.3. This would be easier if I knew what these moving parts are doing to determine how to approach this.
A million thanks before hand for anyone willing to answer this. I know I should have learned this a while ago but later is better than never. Much appreciated!