Failing installing pg gem, mkmf.rb can't find header files for ruby (Mac OSX 10.6.5)
Generally the gem bundles for Postgres want to know where pg_config
is hiding so they can ask about the Postgres installation.
Use locate pg_config
to see if your Mac knows where it's hiding.
I installed a copy of Postgres using mappstack, so my Mac says there's a copy at:
/Applications/mappstack-1.2-3/postgresql/bin/pg_config
and another at:
/Library/PostgreSQL/9.0/bin/pg_config
I don't remember installing the one at /Library/PostgreSQL/9.0
, so it might have been preinstalled by Snow Leopard, or I did it when under the influence of too much work, possibly using the Postgres installer from EnterpriseDB.
Once you've found the location of pg_config
try adding that directory to the start of your PATH and then rerun the gem install.
Or use:
export SQL_PATH=/Library/PostgreSQL/9.0
gem install pg -- --with-pg-config=$SQL_PATH/bin/pg_config
and try installing. If either of those work you're done. Otherwise...
The next thing the installers might want are access to the Postgres headers, so you look in the parent of the bin
directories, and see if you can find an include
directory.
After that, look in that directory for a lib
directory. Once you know those locations you should have all you need to set your environment variables to let the installer complete. You'll need to read the README
or INSTALL
file of the installer and see what needs to be set up. You'll be configuring:
export include_dir=$SQL_PATH/include/
export lib_dir=$SQL_PATH/lib/
gem install pg -- --with-pgsql-include-dir=$include_dir --with-pgsql-lib-dir=$lib_dir
Hopefully that'll all help. I have Rails 3 and my Postgres running fine, using the mappstack Postgres and the EnterpriseDB versions, so the above info should get you there.
gem install pg doesn't work on OSX Lion
I finally found the cause of the problem! Though I am still uncertain how this problem came about.
Look at the contents of the mkmf.log file that is created when my install command fails (see my original post). It logs an attempt to run the following command
/usr/bin/gcc-4.2 ...and so on...
There is no /usr/bin/gcc-4.2
on my system. There is a gcc
, which is symbolically linked to llvm-gcc-4.2
. My solution was to create another symbolic link
sudo ln -s llvm-gcc-4.2 gcc-4.2
After making this link, my gem install pg
command worked without any problems.
I found the solution to this problem on the Frozen Canuck blog in the post Error Installing Ruby Gem with C Extension. He speculates that the problem can be caused by conflicting versions of XCode. whatever the cause, my eternal thanks!
pg gem wont install. Using Postgress.app
this command did the trick for me :
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
For some reason config.gem 'xapian-fu' fails despite gem 'xapian-fu' works?
OK turns out I figured out the answer myself :P
config.gem 'xapian-fu', :lib=>'xapian_fu'
The problem seems because the lib file is being named with the underscore while the gem itself is named with hyphen.
uninitialized constant MysqlCompat::MysqlRes (using mms2r gem)
on my Mac OS X 10.6 I did this to install the 2.8.1 gem, which worked perfectly with my MacPorts mysql5-server:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql
How to get the HTML output from a DataGrid?
var outputBuffer = new StringBuilder();
using (var writer = new HtmlTextWriter(new StringWriter(outputBuffer)))
{
yourDataGrid.RenderControl(writer);
}
outputBuffer.ToString();
Related Topics
Rack::Request - How to Get All Headers
How to Get Past "Http://Gems.Rubyforge.Org/ Does Not Appear to Be a Repository" Error Message
Ruby Minitest: Suite- or Class- Level Setup
Parse Email Addresses for "From" and "To" Fields in Ruby
Building Ruby with Rbenv and Ruby-Build Fails with Undefined Symbol: Sslv2_Method
Rspec --Init Not Working/ 'Mkd Ir': Invalid Argument - ./C: (Errno::Einval)
Ruby Class Inheritance: What Is '<<' (Double Less Than)
Switch Theme in an Existing Jekyll Installation
Storing Arrays in Database Using Activerecord
What Does "+=" (Plus Equals) Mean
How to Find Out Who Is Connected to Actioncable
How to Fire Raw Mongodb Queries Directly in Ruby
In Ruby, Is There No Way to Dynamically Define a Local Variable in the Current Context