Can't find the 'libpq-fe.h header when trying to install pg gem

前端 未结 30 1877
深忆病人
深忆病人 2020-11-22 07:47

I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg gem. It gives me the following error:



        
30条回答
  •  时光取名叫无心
    2020-11-22 08:14

    The location of libpq-fe.h depends on where your PostgreSQL install is (which depends on how you installed it). Use locate (http://en.wikipedia.org/wiki/Locate_%28Unix%29) to find the libpq-fe.h file on your machine. If it exists, it will be in the include directory of your PostgreSQL install.

    $ locate libpq-fe.h
    /Library/PostgreSQL/9.1/include/libpq-fe.h
    

    The bin directory, which contains pg_config, will be in the same directory as the include directory. As the error suggests, use the --with-pg-config option to install the gem:

    $ gem install pg --with-pg-config="/Library/PostgreSQL/9.1/bin/pg_config"
    

    Note that you may need to run updatedb if you have never used locate or if you haven't updated since installing PostgreSQL.

提交回复
热议问题