细找不到pg_ext

Thin can't find pg_ext

我正在尝试 运行 命令

thin -R lat.ru start

目录 50web\servers\dev (lat.ru is part of the open source project 50web).

我收到以下错误:

D:\dev\derekweb\servers\dev>thin -R lat.ru start
C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': ca
nnot load such file -- 2.1/pg_ext (LoadError)
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/pg-0.18.4/lib/pg.rb:14:in `rescu
e in <top (required)>'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/pg-0.18.4/lib/pg.rb:3:in `<top (
required)>'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in
 `require'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in
 `rescue in require'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in
 `require'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/getdb.rb:11:in `<top (required)>
'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from D:/dev/derek/50web/routes/lat.rb:2:in `<top (required)>'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require'
        from lat.ru:3:in `block in <main>'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:5
5:in `instance_eval'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/rack-1.6.4/lib/rack/builder.rb:5
5:in `initialize'
        from lat.ru:1:in `new'
        from lat.ru:1:in `<main>'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/lib/rack/adapter/load
er.rb:33:in `eval'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/lib/rack/adapter/load
er.rb:33:in `load'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/lib/thin/controllers/
controller.rb:182:in `load_rackup_config'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/lib/thin/controllers/
controller.rb:72:in `start'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/lib/thin/runner.rb:20
0:in `run_command'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/lib/thin/runner.rb:15
6:in `run!'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/thin-1.6.4/bin/thin:6:in `<top (
required)>'
        from C:/Ruby21/bin/thin:23:in `load'
        from C:/Ruby21/bin/thin:23:in `<main>'

我正在使用 pg 0.18.4,这似乎是最新版本:

D:\dev\derekweb\servers\dev>gem list pg

*** LOCAL GEMS ***

pg (0.18.4)

D:\dev\derekweb\servers\dev>gem update pg
Updating installed gems
Nothing to update

Ruby 版本为 2.1.7p400 (2015-08-18 revision 51632) [i386-mingw32].

我该如何解决这个错误?

更新 1(02.02.2016 08:08 MSK):

我要 运行 同一项目在不同的机器上:

C:\usr\dp\dev\derekweb\servers\dev>ruby lat.ru
C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- 2.2/pg_ext (LoadError)
        from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg.rb:14:in `rescue in <top (required)>'
        from C:/Ruby22/lib/ruby/gems/2.2.0/gems/pg-0.18.4/lib/pg.rb:3:in `<top (required)>'
        from C:/Ruby22/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'

我注意到 Ruby 似乎在 2.2/pg_ext 目录中寻找 pg_ext 文件,而实际上它安装在 C:\Ruby22\lib\ruby\gems.2.0\gems\pg-0.18.4\lib 目录中。

看来 pg gem 的 C 扩展部分的安装已损坏。

  • 确保安装了 postgresql 开发库
  • 重新安装pggem看看有没有报错

重新安装 -f 强制标志,或者更好的 gem uninstallgem install 重新安装。

我通过卸载 pg gem 并使用 gem install pg --pre 命令重新安装来修复错误。必须的,因为bug,release版本还没有修复