unable to install pg gem

后端 未结 20 785
不知归路
不知归路 2020-12-02 04:54

I tried using gem install pg but it doesn\'t seem to work.

gem install pg gives this error

Temporarily enhancing PATH to in         


        
相关标签:
20条回答
  • 2020-12-02 05:12

    For Mac Users

    PATH=$PATH:/Library/PostgreSQL/9.4/bin/ gem install pg
    

    This should do the trick

    0 讨论(0)
  • 2020-12-02 05:12

    Regardless of what OS you are running, look at the logs file of the "Makefile" to see what is going on, instead of blindly installing stuff.

    In my case, MAC OS, the log file is here:

    /Users/za/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-1.0.0/mkmf.log
    

    The logs indicated that the make file could not be created because of the following:

    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers
    

    Inside the mkmf.log, you will see that it could not find required libraries, to finish the build.

    checking for pg_config... no
    Can't find the 'libpq-fe.h header
    blah blah
    

    After running "brew install postgresql", I can see all required libraries being there:

    za:myapp za$ cat /Users/za/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-1.0.0/mkmf.log | grep yes
    find_executable: checking for pg_config... -------------------- yes
    find_header: checking for libpq-fe.h... -------------------- yes
    find_header: checking for libpq/libpq-fs.h... -------------------- yes
    find_header: checking for pg_config_manual.h... -------------------- yes
    have_library: checking for PQconnectdb() in -lpq... -------------------- yes
    have_func: checking for PQsetSingleRowMode()... -------------------- yes
    have_func: checking for PQconninfo()... -------------------- yes
    have_func: checking for PQsslAttribute()... -------------------- yes
    have_func: checking for PQencryptPasswordConn()... -------------------- yes
    have_const: checking for PG_DIAG_TABLE_NAME in libpq-fe.h... -------------------- yes
    have_header: checking for unistd.h... -------------------- yes
    have_header: checking for inttypes.h... -------------------- yes
    checking for C99 variable length arrays... -------------------- yes
    
    0 讨论(0)
  • 2020-12-02 05:14

    This worked in my case:

    sudo apt-get install libpq-dev
    

    I used:

    • Ubuntu 14.04.2 LTS
    • Ruby 2.2.2
    • Rails 4.2.1
    0 讨论(0)
  • 2020-12-02 05:14

    On macOS (El Capitan). You can simply use: brew install postgresql

    0 讨论(0)
  • 2020-12-02 05:16

    You just go to here to see if your pg version support Win32 platform, then use this command to install:

    gem install pg -v 0.14.1 --platform=x86-mingw32

    0 讨论(0)
  • 2020-12-02 05:17

    Issue is gem dependency so before installing pg make sure you have installed "libpq-dev"

    Ubuntu systems:

    sudo apt-get install libpq-dev

    RHEL systems:

    yum install postgresql-devel

    Mac:

    brew install postgresql

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