Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 无法使用Postgres.app在Mavericks中安装pg gem_Ruby On Rails_Macos_Postgresql_Osx Mavericks_Pg - Fatal编程技术网

Ruby on rails 无法使用Postgres.app在Mavericks中安装pg gem

Ruby on rails 无法使用Postgres.app在Mavericks中安装pg gem,ruby-on-rails,macos,postgresql,osx-mavericks,pg,Ruby On Rails,Macos,Postgresql,Osx Mavericks,Pg,我正在尝试在本地计算机上安装pg gem,以便与Postgres.app一起使用。我是小牛队的 Postgres.app已安装并运行良好,但我无法让gem正常工作。我已经做了以下工作: 使用Postgres.app文档中的命令'env ARCHFLAGS=“-arch x86_64”gem install pg--with pg config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config' 更新了自制软件并安装了Apple GCC

我正在尝试在本地计算机上安装pg gem,以便与Postgres.app一起使用。我是小牛队的

Postgres.app已安装并运行良好,但我无法让gem正常工作。我已经做了以下工作:

  • 使用Postgres.app文档中的命令'env ARCHFLAGS=“-arch x86_64”gem install pg--with pg config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
  • 更新了自制软件并安装了Apple GCC 4.2
  • 安装了Xcode开发工具
  • 更新了my$PATH以引用Postgres.app bin和lib目录
  • 都没有成功。以下是我收到的具体错误消息:

    Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
    This could take a while...
    ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.
    
        /Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
    Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
    sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
    sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
    checking for libpq-fe.h... no
    Can't find the 'libpq-fe.h header
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    
    Provided configuration options:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
        --with-pg
        --without-pg
        --with-pg-config
        --with-pg-dir
        --without-pg-dir
        --with-pg-include
        --without-pg-include=${pg-dir}/include
        --with-pg-lib
        --without-pg-lib=${pg-dir}/
    

    如果你能提供帮助,我将不胜感激。谢谢

    对于
    ,您可能有错误的路径——使用pg config
    ,检查它是否确实在那里

    您可以通过以下方法找到
    pg_config
    的正确路径:

    find /Applications -name pg_config
    
    在最新的Postgres.app版本中,路径为:

    gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
    

    为了解决这个问题,我在终端窗口中使用以下程序使用自制软件安装了postgres:

    brew install postgres
    
    在这里可以找到自制的


    在一台全新的mac电脑上,我要做的是:

  • 从应用商店安装Xcode工具
  • 打开Xcode工具并接受许可证
  • 现在运行(希望是经过未来验证的命令):

    version=$(ls/Applications/Postgres.app/Contents/Versions/| tail-1)
    gem安装pg--with pg config=/Applications/Postgres.app/Contents/Versions/$version/bin/pg_config.

  • 如果您遇到问题,可以通过检查mkmf.log中的实际错误来进行故障排除,您可以通过运行(如果使用rvm)找到该错误:

    在我的情况下(运行Postgres.app v9.3.4.2),它似乎只在预先设置环境架构标志时起作用:

    env ARCHFLAGS="-arch x86_64" gem install pg -- \
    --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config 
    

    我可以用这个命令安装pg

        gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
    
    我通过跑步找到了自己的路

        sudo find / -name "pg_config"
    
    我成功地安装了pg-0.17.1,这对我来说很有用:

    gem install pg -- --with-pg-config=`which pg_config`
    

    将postgress bin dir添加到路径中也可以做到这一点。只需像这样把垃圾桶添加到pat中。对于最近的安装,最新的符号链接确保此路径对于将来的版本升级应该是“稳定的”

    export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
    

    供将来参考,因为我们很多人都在发布新版本号的新路径:

    目前,我在
    /Applications/Postgres.app/Contents/Versions/
    中看到一个名为
    latest
    的符号链接

    你应该能够做到:

    $ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
    

    忘了版本号吧。这可能不适用于所有(旧的)版本,但我自己正在寻找一个可以保存和重用的代码片段。

    可能是令人尴尬的重复,就是这样。升级到Postgres.app的最新版本后,路径发生了变化,我没有注意到。谢谢这也是给我的!谢谢你!出于某种原因,在我的安装中,我必须运行
    $gem install pg--with pg config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config.
    较新的Postgres.app安装可能需要您使用此命令
    gem install pg--with pg config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config.
    以供进一步参考,我昨天刚下载了Postgres.app,我的pg_配置位于
    Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
    。通过使用
    ls
    查看
    Applications/Postgres.app/Contents
    目录,应该能够找出他们的pg_配置在哪里。查看您是否有
    /Contents/MacOS
    /Contents/Versions
    …这是最新版本Postgres应用程序的正确路径。重要的是--,它必须是pg中的一个错误。这确实解决了问题,但这意味着只为一个头文件安装一个完整的其他Postgres。是的,如果使用Postgres.App,请不要这样做。事实上,如果有postgres,您应该运行
    brew uninstall postgres
    。您可以通过包含
    export ARCHFLAGS=“-arch x86_64”
    将ARCHFLAGS放入.bash_配置文件(或等效文件)中。对我来说,没有这个,PG就不能工作。我正在使用bundler,我花了一点时间才弄明白如何将它添加到
    bundle
    命令中。您可以使用
    bundle config pg.build“…”
    ,查看更多信息使用此命令更容易找到
    pg_config
    文件,因此您不必搜索计算机上的所有文件:
    $find/Applications/Postgres.app/-name“pg_config”
    搜索
    /Library/
    将在您的计算机上运行。谢谢,在
    gem-install
    中预先设置此选项效果良好:
    PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin gem-install pg
    $ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config