Search code examples
ruby-on-railsrubyrubygemspg

Cannot run "rails server" because of failure to install 'pg' in gem


I am new to ruby on rails and I just downloaded a new Rails project directory that my friend sent to me. I put that directory on the Desktop and cd into it. I want to play with the code on my local host to learn from the code. But when I tried to run "rails s", it gives me the error saying that

"Could not find pg-0.17.1 in any of the sources
 Run `bundle install` to install missing gems."

So I ran "bundle install", then it gave the error that

"An error occurred while installing pg (0.17.1), and Bundler cannot continue.
 Make sure that `gem install pg -v '0.17.1'` succeeds before bundling."

I googled the problem for a while but I did not find any solution.. "rails s" stills works fine in my own project's directory. But how can I make it work in the directory I just downloaded? Am I supposed to do some other setup or installing?


Solution

  • Here how I made development environment on my Mac.

    Install PostgreSQL via Homebrew package manager brew install postgresql. This should install all necessary header files for gem compilation.