我刚升级到Rails 3,需要整理的MacPorts、gems和数据库有点乱.我扔掉了所有的Ruby ,重新安装.除了pg gem的要求外,一切似乎都很好.
在创建了一个新的Rails 3项目(为PostgreSQL做准备)之后,服务器无法启动,抱怨缺少pg gem.完成bundle install
分后,它开始了一段时间,当然,在pg gem上失败了.
Installing pg (0.10.0) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.10.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.10.0/ext/gem_make.out
from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `each'
from /Library/Ruby/Site/1.8/rubygems/installer.rb:446:in `build_extensions'
from /Library/Ruby/Site/1.8/rubygems/installer.rb:198:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `send'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19
我在论坛和博客上发现的最常见的建议是(重新)安装XCode开发工具.它们已经在那里了,但我还是重新安装了它们,没有比上面更好的结果.
which ruby
表示/usr/bin/ruby
,ruby -v
表示ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
,如果有任何线索的话.
欢迎指点.任何有助于解决这一问题的缺失信息,我都乐意及时提供!
我下载了XCode,因为DVD版本据说已经坏了,事情好了一段时间.bundle install
开始谈论"archflags",于是我:
sudo env ARCHFLAGS="-arch i386" bundle install
事情似乎进展顺利,直到起跑轨吐了出来,说:
/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle, 9): no suitable image found. Did find: (LoadError)
/Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/pg-0.10.0/lib/pg_ext.bundle
为了 payable 任何事情,我try 了bundle install
次,把archflags设置为-arch x86_64
,但效果不好:
*** Your PostgreSQL installation doesn't seem to have an architecture in common with the running ruby interpreter ([] vs. ["x86_64"])
I'll continue anyway, but if it fails, try setting ARCHFLAGS.
[...]
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
libpq是我现在必须通过一些标志提供的路径吗?还是我完全出go 吃午饭了?