Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Can not load the rails server

I am in the treebook folder, and I type rails -s...

garans-mbp:treebook garanguillory$ rails s
Could not find gem 'pg (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.

Then I type bundle install...

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/garanguillory/.rbenv/versions/1.9.3-p545/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/garanguillory/.rbenv/versions/1.9.3-p545/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib


Gem files will remain installed in /Users/garanguillory/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/pg-0.17.1 for inspection.
Results logged to /Users/garanguillory/.rbenv/versions/1.9.3-p545/lib/ruby/gems/1.9.1/gems/pg-0.17.1/ext/gem_make.out
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 am working on Building Social Features in Ruby on Rails / Creating Friendships. I am going to use the same project files that I have worked with since I started the Ruby on Rails track.

I am running ruby version 1.9.3p545 and rails, well I am trying to downgrade it to version 3.2.6 (it is currently at 4.1.1). I am having difficulty doing so. Regardless, somebody please post a solution to my problems. I want to continue following along with this track.

3 Answers

it doesn't look like a deployment, I'm not sure here but how about trying

bundle install --without production

because there could be a condition in Gemfile, production for 'pg'

Have you installed PostgreSQL on your Mac? The 'gem pg' works as a bridge between your Postgres server and the rails webserver.

To check if you have Postgres installed, open your terminal and type: psql --version

If its not installed, it is simple to install it with Homebrew (http://brew.sh)

With homebrew you can run the command in terminal: brew install postgresql

After its installed you will need to start the Postgresql serrver. Note that each time you start your mac you will need to start your PG server. However in your bash_profile you can add command lines that will make PG start automatically.

Check out this video by Ryan Bates, its very helpful http://railscasts.com/episodes/342-migrating-to-postgresql

Aurelien

Thanks for y'all's quick replies. Your solution worked kang kyu lee . Should I follow through with Aurelien Schlumberger 's solution as well?

I tried running psql -version in my terminal, and I was alerted "psql: command not found."

Should I install Postgresql? (I assume it is not installed if I can not find the version number.)

Yes, try postgresql with rails if you'd like to... currently in treehouse ActiveRecord Basics deals mysql, however. Like Aurelien said, go and copy and paste the command in the bottom of homebrew page... and try

brew install postgresql
psql --version
brew info postgresql

and other ways around.