Can't install pg gem on Rails

后端 未结 3 1136
无人及你
无人及你 2020-12-30 03:52

I am trying to bundle install, but, for some strange reason, the pg gem is returning the following error on install:

$ gem install pg -v \'0.18.4\'
Building          


        
相关标签:
3条回答
  • 2020-12-30 04:10

    If the PostgreSQL client library is installed, then you need to tell gem where to look for the include files, which it does by asking pg_config. I use a little shell file to make it easier for gem to find that utility:

    #!/bin/sh -x
    
    PATH=/Library/PostgreSQL/9.4/bin:$PATH
    gem install pg $@
    

    You could also manually adjust your PATH to always include the PostgreSQL bin directory, which should fix the problem permanently.

    If you upgrade your PostgreSQL that path will change, so you might need to reinstall pg and/or change your PATH setting.

    Once pg is installed, further upgrades to the gem will be able to install without rerunning the script.

    0 讨论(0)
  • 2020-12-30 04:24

    You should probably install the PostgreSQL development libraries.

    If you're on Ubuntu this will help:

    sudo apt-get install libpq-dev
    

    On a Mac:

    brew install postgresql
    
    0 讨论(0)
  • 2020-12-30 04:28

    You need to configure pg correctly.

    Run:

    bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/Versions/(YOUR POSTGRES VERSION)/bin/pg_config
    

    Then try to run bundle:

    bundle install
    
    0 讨论(0)
提交回复
热议问题