2

我有两个 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'

但这不是可接受的解决方案,我想知道为什么它适用于第一个应用程序以及为什么它不适用于新应用程序?我花了一整天比较配置文件,但没有成功。

4

1 回答 1

1

升级到 Fedora 18 后我遇到了同样的问题。

pg_ext 在运行 gem update 时构建。

一个先决条件是安装了 postgresql-devel。

于 2013-01-30T19:43:06.307 回答