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
最满意答案
一个单例的主要优点在于一个由静态组成的类,你可以稍后轻松地决定你实际上需要一个以上的实例,例如每个线程一个。
然而,在实践中,单身人士的主要目的是让人们对全球变数感到不好。
一个很好的使用单例的实例:你有一个使用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".
相关问答
更多-
单身人士和常量(Singletons and constants)[2024-02-10]
没有关于C#的措辞,但在Java中有几种方法可以解决这个问题。 将访问修饰符更改为默认(仅包)或public 。 最直接的解决方案。 将它们分组在私有或public enum 。 如果这些值彼此相关 ,则最直接。 例如Role.ADMIN , Role.USER , Role.GUEST等。 将它们声明在包私有或public interface并让这些类实现它。 只有在这些常量属于某些合同时,这些类才能遵守。 将它们放在属性文件中并加载为private static final Properties并添加一 ... -
缩放单身人士(Scaling singletons)[2023-11-14]
对于不同的“实例”,不同的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 ...
-
编程中单身人士的宗旨(Purpose of singletons in programming)[2021-01-27]
一个单例的主要优点在于一个由静态组成的类,你可以稍后轻松地决定你实际上需要一个以上的实例,例如每个线程一个。 然而,在实践中,单身人士的主要目的是让人们对全球变数感到不好。 一个很好的使用单例的实例:你有一个使用SQL数据库的应用程序,你需要一个连接池。 这样的池的目的是重用数据库连接,所以你绝对希望所有客户端使用相同的池。 因此,将它作为单身是正确的设计。 但有一天,您需要该应用程序连接到第二个 DB服务器,并且意识到您不能连接到同一池中的不同服务器。 因此,您的“一体整体”单例变为“每个DB服务器一个实 ... -
要记住的关键是设计模式只是一个帮助您理解抽象概念的工具。 一旦你有了这个理解,把你自己专门限制在一本书中的“食谱”就没有意义了,并且伤害了你编写最适合你目的的代码的能力。 也就是说,阅读GoF这样的书籍将会给您更多的方式来思考问题,以便在时候自行实施某些事情的时候,您会有更广泛的观点来解决问题。 在你的情况下,如果在每一种情况下使用单身人士都是有道理的,那么就要走在前面。 如果它“适合”,你必须以一些笨重的方式实现它,那么你需要提出一个新的解决方案。 强制不完美的图案有点像在圆孔中敲一个方形钉。 鉴于你说“ ...
-
斯威夫特单身人士(Singletons In Swift)[2023-10-30]
回到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. -
单身人士和ICommand(Singletons and ICommand)[2023-01-01]
由于类遵循单例模式,因此行为应该没有任何差异。 任何引用单例的东西都不会关心如何限制类的构造,只关注类的实例是否存在。 问题可能在于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 ...