Rails:安装pg gem时出错

编程入门 行业动态 更新时间:2024-10-28 14:25:35
本文介绍了Rails:安装pg gem时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

可能重复: Postgres- pg的最新版本0.14.0宝石给出错误

我是新手。我想使用PostgreSQL,因为Heroku也使用PostgreSQL,但是我在安装 pg gem时遇到了麻烦。显然,某些文件丢失了,无法创建Makefile?

I'm new to rails. I want to use PostgreSQL since Heroku uses it too, but I'm having a bad time installing the pg gem. Apparently, some files are missing and a Makefile cannot be created?

我的gem文件如下:

source 'rubygems' gem 'rails', '3.2.6' gem 'faker', '1.0.1' gem 'pg', '0.12.2' gem 'json' group :development, :test do gem 'rspec-rails', '2.10.0' end group :assets do gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails', '2.0.0' group :test do gem 'capybara', '1.1.2' gem 'factory_girl_rails', '1.4.0' end

当我运行捆绑安装时,安装pg gem时出现以下错误:

And when I run bundle install I get the following error when installing the pg gem:

Installing pg (0.14.0) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb checking for pg_config... yes Using config values from /usr/local/bin/pg_config checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes checking for pg_config_manual.h... yes checking for PQconnectdb() in -lpq... no checking for PQconnectdb() in -llibpq... no checking for PQconnectdb() in -lms/libpq... no Can't find the PostgreSQL client library (libpq) *** 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 --without-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=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby --with-pg --without-pg --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pqlib --without-pqlib --with-libpqlib --without-libpqlib --with-ms/libpqlib --without-ms/libpqlib Gem files will remain installed in /Users/KennyGWang/.bundler/tmp/18833/gems/pg-0.14.0 for inspection. Results logged to /Users/KennyGWang/.bundler/tmp/18833/gems/pg-0.14.0/ext/gem_make.out An error occured while installing pg (0.14.0), and Bundler cannot continue. Make sure that `gem install pg -v '0.14.0'` succeeds before bundling.

我使用自制软件安装了postgresql,酿造了postgresql ,因此 psql 给了我 / usr / local / bin / psql

I installed postgresql using homebrew, brew install postgresql, thus which psql gives me /usr/local/bin/psql

感谢您的帮助!

推荐答案

您在Mac上吗?如果是这样,最简单的方法是

Are you on a Mac? If so - the easiest way to do this is to

  • 确保已安装Xcode(可以从应用商店中获取)
  • 使用自制软件
  • brew安装postgresql
  • gem卸载pg
  • 在应用程序根目录中的捆绑安装或 gem安装pg
  • make sure you have Xcode installed (you can get it from the app store)
  • use Homebrew
  • brew install postgresql
  • gem uninstall pg
  • either bundle install in your application's root or gem install pg
  • 更多推荐

    Rails:安装pg gem时出错

    本文发布于:2023-10-13 20:16:23,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1488972.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Rails   pg   gem

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!