我有两个rails应用程序,“旧”一个和新一个,用
创建 $ rails new blog -d postgresql
当我尝试启动服务器时,它可以正常使用“旧”应用程序:
$ rails s -p 2000
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:2000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-09-17 16:28:48] INFO WEBrick 1.3.1
[2012-09-17 16:28:48] INFO ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-09-17 16:28:48] INFO WEBrick::HTTPServer#start: pid=9377 port=2000
但是“新”应用程序失败了:/
$ rails s -p 2000
/usr/local/share/gems/gems/pg-0.14.1/lib/pg.rb:4:in `require': cannot load such file -- pg_ext (LoadError)
from /usr/local/share/gems/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
from /home/alex/tmp/RoR/blog/config/application.rb:7:in `<top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
如果我将pg_ext.so复制或符号链接到模块路径,则可以修复:
# ln -s /usr/local/share/gems/gems/pg-0.14.1/ext/pg_ext.so /usr/local/share/gems/gems/pg-0.14.1/lib
或者我可以直接将需求添加到boot.rb:
require 'rubygems'
require 'pg'
但这是不可接受的解决方案,我想知道为什么它适用于第一个应用程序以及为什么它不适用于新应用程序?我花了一整天时间比较配置文件但没有成功。
答案 0 :(得分:1)
升级到Fedora 18后我遇到了同样的问题。
pg_ext是在运行gem update时构建的。
先决条件是安装了postgresql-devel。