【发布时间】:2012-08-29 17:21:04
【问题描述】:
升级到 Mountain Lion 后,我在使用 Rails 时遇到了很多麻烦。
到目前为止,我尝试解决这些问题并在互联网上搜索了几个小时,以确保我的系统在升级后具有运行 rails 的所有依赖项:
- 我更新了 Homebrew 安装
- 我更新了我的 RVM 安装
- 我安装了 XCode 命令行工具
- 我安装了 GCC as mentioned
- 我将我的 Ruby 版本升级到
ruby 1.9.2p290(2011-07-09 修订版 32553)[x86_64-darwin10.8.0]
- 我的 Rails 版本被验证为 Rails 3.2.6
-
我还发现 Mountain Lion 的 Postgres 存在一些问题,所以我看到 this post 并发现我需要将这一行添加到我的 Bash 个人资料中:
export PATH="/usr/local/bin:/usr/bin:$PATH"
现在我转到我升级之前在 Snow Leopard 上运行良好的 Rails 应用程序,当我在命令行运行 rails s 时出现以下错误:
AM@~/Documents/RailsWS/app0815 >gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
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
--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/AM/.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
/Users/AM/.rvm/rubies/ruby-1.9.2-p290/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/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:853:in `block in find_header'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
from extconf.rb:41:in `<main>'
Gem files will remain installed in /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.14.1 for inspection.
Results logged to /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.14.1/ext/gem_make.out
当我转到 Rails 应用程序并尝试 bundle install 时,它在 pg 安装时失败。
【问题讨论】:
-
请注意,您的 Rails 和 Ruby 版本都很旧并且存在已知的安全漏洞。截至目前的最新版本是 Rails 3.2.8 和 Ruby 1.9.2-p320/1.9.3-p194。
-
您是否像我之前在您的(现已删除?)问题中推荐的那样通过自制软件安装了postgres?
-
@Deefour 我不记得看过你的回复。
标签: ruby-on-rails macos postgresql osx-mountain-lion