0

So I would like to deploy my rails app on heroku right? Wanna switch from sql3 to postgresql. Should be simple but I keep getting an error when trying to bundle with gem 'pg' in my gemfile. I used homebrew to install postgresql with all its native extensions before trying to bundle. Any ideas? I am on Mac OSX high sierra.

An error occurred while installing pg (1.1.3), and Bundler cannot continue. Make sure that gem install pg -v '1.1.3' --source 'https://rubygems.org/' succeeds before bundling.

That's all I get for the error. Not helpful. I went ahead and uninstalled postrgresql that I installed locally to my machine from their website as well as with homebew. Gonna start from scratch. I haven't done this in years so any help would be appreciated!

dmberko11
  • 427
  • 7
  • 17

2 Answers2

0

I've run into this before where you attempt to install the PG gem, but postgres is not yet installed. Even if you install postgres after that, you'll still run into troubles (this has to do with required libraries not being available or not found). I would recommend uninstalling both, then installing Postgres first, then the PG gem. This is a common gotcha, unfortunately: Installing PG gem on OS X - failure to build native extension Also, I would recommend https://postgresapp.com/ if you continue to have trouble installing PG or having the gem not see your install properly.

jmccartie
  • 4,956
  • 8
  • 50
  • 71
  • the real headscratcher was I actually installed the posgresql app prior to trying to install the gem. Still got the error. – dmberko11 Sep 12 '18 at 21:01
  • Yeah, it can still happen if the path to the binary is not right. It’s brittle, for sure. – jmccartie Sep 13 '18 at 02:06
0

After tons of research and trying everything, found an older question on stackoverflow from 2014. If you install postgresql with homebrew like I did, running the command ARCHFLAGS="-arch x86_64" gem install pg will install the gem if bundling or gem install pg don't work. Hope that helps other people who might be stuck like I was

dmberko11
  • 427
  • 7
  • 17