首页 \ 问答 \ Rails 3 - 无法安装pg gem(Rails 3 - can't install pg gem)

Rails 3 - 无法安装pg gem(Rails 3 - can't install pg gem)

当我尝试运行bundle(bundle install)时,我一直都会得到

Installing pg (0.13.2) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
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
    --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=/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/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


Gem files will remain installed in /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2 for inspection.
Results logged to /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
An error occured while installing pg (0.13.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.13.2'` succeeds before bundling.

我使用Mac OS X 10.6,安装PostgreSQL的版本是9.1。 我发现问题是在libpq-dev ,我该如何安装/修复?


When I try to run bundle (bundle install), I all the time get

Installing pg (0.13.2) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/ryan/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
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
    --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=/Users/ryan/.rvm/rubies/ruby-1.9.2-p290/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


Gem files will remain installed in /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2 for inspection.
Results logged to /Users/ryan/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.13.2/ext/gem_make.out
An error occured while installing pg (0.13.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.13.2'` succeeds before bundling.

I use Mac OS X 10.6, the version of installed PostgreSQL is 9.1. I found the problem is in the libpq-dev, how could I install/fix that?


原文:https://stackoverflow.com/questions/9668753
更新时间:2023-06-15 06:06

最满意答案

一个单例的主要优点在于一个由静态组成的类,你可以稍后轻松地决定你实际上需要一个以上的实例,例如每个线程一个。

然而,在实践中,单身人士的主要目的是让人们对全球变数感到不好。

一个很好的使用单例的实例:你有一个使用SQL数据库的应用程序,你需要一个连接池。 这样的池的目的是重用数据库连接,所以你绝对希望所有客户端使用相同的池。 因此,将它作为单身是正确的设计。 但有一天,您需要该应用程序连接到第二个 DB服务器,并且意识到您不能连接到同一池中的不同服务器。 因此,您的“一体整体”单例变为“每个DB服务器一个实例”。


The main advantage of a singleton over a class consisting of statics is that you can later easily decide that you need in fact more than one instance, e.g. one per thread.

However, in practice the main purpose of singletons is to make people feel less bad about having global variables.

A practical example for a good use of a singleton: you have an app that uses an SQL database and you need a connection pool. The purpose of such a pool is to reuse DB connection, so you definitely want all clients to use the same pool. Thus, having it as a singleton is the correct design. But one day you need the app to connect to a second DB server, and realize that you cannot have connections to different servers in the same pool. Thus your "one instance overall" singleton becomes "one instance per DB server".

相关问答

更多
  • 没有关于C#的措辞,但在Java中有几种方法可以解决这个问题。 将访问修饰符更改为默认(仅包)或public 。 最直接的解决方案。 将它们分组在私有或public enum 。 如果这些值彼此相关 ,则最直接。 例如Role.ADMIN , Role.USER , Role.GUEST等。 将它们声明在包私有或public interface并让这些类实现它。 只有在这些常量属于某些合同时,这些类才能遵守。 将它们放在属性文件中并加载为private static final Properties并添加一 ...
  • 对于不同的“实例”,不同的AppDomain怎么样? What about different AppDomains for different "Instances"?
  • 如果你想在ClassLoader之间共享一个单例,你有一个共同的父加载单例,或者你可以让每个ClassLoader明确定义你希望该类加载器使用哪些类Singleton。 If you want share a singleton between ClassLoaders, you have a common parent load the singleton, or you can have each ClassLoader explicitly define which classes Singleton ...
  • 通常,单个类中的多个静态变量没有问题。 其中只有一个应该被称为单例 - 即imageManager ,因为这是在您的设计中将是唯一的实例。 但是,如果ImageManager需要独占使用NSCache ,最好使imageCache成为ImageManager的实例属性。 如果其他静态方法需要访问缓存,他们总是可以通过imageManager.imageCache访问它。 Generally, there is no problem with multiple static variables in a si ...
  • 一个单例的主要优点在于一个由静态组成的类,你可以稍后轻松地决定你实际上需要一个以上的实例,例如每个线程一个。 然而,在实践中,单身人士的主要目的是让人们对全球变数感到不好。 一个很好的使用单例的实例:你有一个使用SQL数据库的应用程序,你需要一个连接池。 这样的池的目的是重用数据库连接,所以你绝对希望所有客户端使用相同的池。 因此,将它作为单身是正确的设计。 但有一天,您需要该应用程序连接到第二个 DB服务器,并且意识到您不能连接到同一池中的不同服务器。 因此,您的“一体整体”单例变为“每个DB服务器一个实 ...
  • 要记住的关键是设计模式只是一个帮助您理解抽象概念的工具。 一旦你有了这个理解,把你自己专门限制在一本书中的“食谱”就没有意义了,并且伤害了你编写最适合你目的的代码的能力。 也就是说,阅读GoF这样的书籍将会给您更多的方式来思考问题,以便在时候自行实施某些事情的时候,您会有更广泛的观点来解决问题。 在你的情况下,如果在每一种情况下使用单身人士都是有道理的,那么就要走在前面。 如果它“适合”,你必须以一些笨重的方式实现它,那么你需要提出一个新的解决方案。 强制不完美的图案有点像在圆孔中敲一个方形钉。 鉴于你说“ ...
  • 回到Swift的一天, static let还没有实现。 解决方法是创建一个包装struct 。 随着Swift 2 ,这不再需要。 Back in Swift 1 days, static let wasn't implemented yet. The workaround was to create a wrapper struct. With Swift 2, this is not needed anymore.
  • 由于类遵循单例模式,因此行为应该没有任何差异。 任何引用单例的东西都不会关心如何限制类的构造,只关注类的实例是否存在。 问题可能在于ViewModel的PropertyChanged事件与Command上的CanExecuteChanged之间缺少正确的链接。 There shouldn't be any difference in the behavior due to the fact that a class follows the singleton pattern. Anything with a ...
  • 我并不讨厌单身人士,但这听起来像是一个对他们毫无用处的情况。 我不明白为什么那篇文章中有这么多单身人士。 首先,PanelStack本身就是一个单身人士。 为什么? 如果这是你的主要小部件,那么只需在main()中的堆栈上创建它,它既更干净又更快。 如果它是更复杂的UI的一部分,那么将其作为该UI的成员放在那里。 常规类在这里很好,使单例仅限制其可能的用途。 那么,每个面板也是单身? 在这一点上,即使是单身爱好者也应该开始觉得他们已经有太多了。 这可能就是你首先提出这个问题的原因。 让我们看看单身人士在这里 ...
  • 这一切都在“服务”的名称。 服务,就像控制器之间的通信媒介,甚至是指令。 不仅用于通信,您还可以在服务中添加一组实用程序功能,这些功能可以在整个模块/应用程序中使用。 这不需要有多个实例来实现此目的。 因此,单身人士。 It all falls in the name "Service". Service, acts like a medium to communicate between controllers or even directives for that matter. Not only fo ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)