我必须将 Rails 应用程序重新安装到全新的 OSX Snow Leopard 上。
我花了很长时间才尝试让 pg gem 正确安装在 Rails 上。首先我通过这个安装了 PgSql 9关联。但是,当我尝试运行 bundle install 时,我开始收到错误:
Installing pg (0.10.0) with native extensions /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:529:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/Users/Chris/.rvm/rubies/ruby-1.9.2-p136/bin/ruby extconf.rb
checking for pg_config... yes
Ruby cflags: " -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe"
MacOS X build: fixing architecture flags:
finding flags common to both Ruby and PostgreSQL...
*** Your PostgreSQL installation doesn't seem to have an architecture in common with the running ruby interpreter (["ppc", "i386", "x86_64"] vs. [])
I'll continue anyway, but if it fails, try setting ARCHFLAGS.
testing for architecture: "ppc"
testing for architecture: "i386"
testing for architecture: "x86_64"
checking for libpq-fe.h... *** 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/Chris/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-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}/lib
/Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
from extconf.rb:123:in `<main>'
Gem files will remain installed in /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/pg-0.10.0 for inspection.
Results logged to /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/pg-0.10.0/ext/gem_make.out
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:507:in `block in build_extensions'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `each'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:482:in `build_extensions'
from /Users/Chris/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:156:in `install'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/source.rb:96:in `install'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/installer.rb:55:in `block in run'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/bin/bundle:19:in `load'
from /Users/Chris/.rvm/gems/ruby-1.9.2-p136/bin/bundle:19:in `<main>'
我遇到了这个文章,建议我通过 Mac Ports 安装 PgSql 8.3。所以我照做了,并按照文章中的其余说明进行操作。我设法捆绑安装并通过以下方式启动 rails 服务器轨道没有任何问题。
我主要担心的是,我相信我安装了 2 个 PgSql。一个是版本 9,另一个是版本 8.3。无论出于什么原因,我是否应该卸载版本 9?还是最新的安装会覆盖?
或者我不应该担心这个?其次,我到处寻找有关如何在 Mac OSX 上卸载版本 9 的正确文档,但无济于事。
答案1
我不知道它在 Mac 上是如何工作的,但在 Linux 上,EnterpriseDB 安装程序会留下一个卸载脚本,可能链接到某个菜单项。你应该寻找一下。
这两个安装应该能够和平共处。但是如果您不需要该安装,则理所当然地应该考虑将其删除。
总的来说,我确实建议使用 Macports 来运行 PostgreSQL 和其他软件。