I\'m getting an error when I run brew in the terminal:
brew
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core
To me it feels like you have missing header files for popen, which is a C system library.
Check if you have installed xcode successful with the command line tools and have accepted the license.
See this thread for more information: How to install Xcode Command Line Tools