Error installing pg gem on osx

后端 未结 10 888
Happy的楠姐
Happy的楠姐 2020-12-24 15:38

I am on osx 10.6.7 trying to run bundle install on a new rails 3.0.7 app and it keeps failing when trying to build the pg gem. It keeps telling me that I have need the devel

相关标签:
10条回答
  • 2020-12-24 16:03

    I also ran into this issue, for me the answer was updating RVM of all things.

    rvm get head
    rvm install 1.9.2
    
    0 讨论(0)
  • 2020-12-24 16:04

    Some correction. For those who have installed postgres using homebrew.

    1) write the following line in your ~/.bash_profile

    export ARCHFLAGS="-arch x86_64"

    2) restart console

    3) execute following command

    bundle config build.pg --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config (this has to be your pg config address, can differ for each depending on versions of postgres)

    4) Install pg once locally by running this command

    sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config

    5) bundle install

    0 讨论(0)
  • 2020-12-24 16:07

    If you are using the PostgreSQL app on osx, you may need to change path the following (as the location of the binaries and config files changes) instead of the path shown in lesyk's answer:

    export PATH=/Applications/Postgres.app/Contents/MacOS/bin:${PATH}
    
    0 讨论(0)
  • 2020-12-24 16:07

    I'm on the same OSX and XCode version as you are: bundle install with pg 0.11.0 works fine to me. However, I found this article that might be able to help you fixing-the-you-have-to-install-development-tools-first-error-with-nokogiri

    If you're using rvm, you can try:

    rvm update head  
    rvm --force install
    1.9.2 gem install bundle
    

    Here my stack:

    [ 08:36:26 ] > bundle install
    Fetching source index for http://rubygems.org/
    Enter your password to install the bundled RubyGems to your system: 
    Using rake (0.8.7) 
    Using abstract (1.0.0) 
    Installing activesupport (3.0.7) 
    Installing builder (2.1.2) 
    Installing i18n (0.5.0) 
    Installing activemodel (3.0.7) 
    Using erubis (2.6.6) 
    Using rack (1.2.2) 
    Installing rack-mount (0.6.14) 
    Installing rack-test (0.5.7) 
    Installing tzinfo (0.3.27) 
    Installing actionpack (3.0.7) 
    Using mime-types (1.16) 
    Installing polyglot (0.3.1) 
    Installing treetop (1.4.9) 
    Installing mail (2.2.19) 
    Installing actionmailer (3.0.7) 
    Installing arel (2.0.9) 
    Installing activerecord (3.0.7) 
    Installing activeresource (3.0.7) 
    Using bundler (1.0.10) 
    Installing pg (0.11.0) with native extensions 
    Using thor (0.14.6) 
    Installing railties (3.0.7) 
    Installing rails (3.0.7) 
    Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
    [ ronda@MacBook ~/Projects/rails_projects/first_app ]
    [ 08:42:57 ] > rails server
    => Booting WEBrick
    => Rails 3.0.7 application starting in development on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2011-04-27 20:45:27] INFO  WEBrick 1.3.1
    [2011-04-27 20:45:27] INFO  ruby 1.9.2 (2011-02-18) [x86_64-darwin10]
    [2011-04-27 20:45:27] INFO  WEBrick::HTTPServer#start: pid=4757 port=3000
    
    0 讨论(0)
  • 2020-12-24 16:07

    I was stuck on my bundle install for 3 days. Tried Everything like adding env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config

    I was able to see pg gem getting installed after this command but still it was not installing from bundle install, which was a pain because I dint know what to write in Gemfile except gem 'pg'

    The thing which finally worked for me was to find that my pg_config was in /Library/PostgreSQL/9.3/bin/pg_config and by default the Gemfile bundle install looks in /usr/local/bin/pg_config

    I just ran the following command and magic happened. bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config

    0 讨论(0)
  • 2020-12-24 16:08

    I had the same issue. For me the fix was:

    sudo ln -s gcc /usr/bin/gcc-4.2

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