如何解决需要来自 Ruby 3.0 的 pg 时,获取“找不到指定的模块”
我已经使用它们各自的安装程序安装了最新版本的 Ruby 和 PostGre。
确切的版本是:
- Ruby 3.0.2 和 Devkit 来自:https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.0.2-1/rubyinstaller-devkit-3.0.2-1-x64.exe
- PostGresql 13.3 来自:https://www.enterprisedb.com/postgresql-tutorial-resources-training?cid=437(这是官方页面指向的版本)。
我已经安装了 PostGre gem:
gem install pg -- --with-pg-dir="C:\path\to\PostGre"
成功安装了 pg-1.2.3 gem。
然而,当我在 IRB 中执行 require 'pg'
时,我收到一条错误消息:
C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/dll_directory.rb:83:in 'add_dll_directory_winapi': AddDllDirectory Failed for C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/x64-mingw32 (RubyInstaller::Runtime::DllDirectory::WinApiError)
from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/dll_directory.rb:50:in 'initialize'
from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/singleton.rb:12:in 'new'
from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/singleton.rb:12:in 'add_dll_directory'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:15:in 'block in <top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:26:in 'rescue in <top (required)>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:4:in '<top (required)>'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in 'require'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in 'rescue in require'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in 'require'
from (irb):1:in '<main>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in '<top (required)>'
from C:/Ruby30-x64/bin/irb.cmd:31:in 'load'
from C:/Ruby30-x64/bin/irb.cmd:31:in '<main>'
<internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in 'require': 126: Le module spécifié est introuvable.
- C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg_ext.so (LoadError)
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in 'require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:5:in '<top (required)>'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in 'require'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in 'rescue in require'
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in 'require'
from (irb):1:in `<main>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in '<top (required)>'
from C:/Ruby30-x64/bin/irb.cmd:31:in `load'
from C:/Ruby30-x64/bin/irb.cmd:31:in `<main>'
<internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in 'require': cannot load such file -- pg (LoadError)
from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in 'require'
from (irb):1:in '<main>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.5/exe/irb:11:in '<top (required)>'
from C:/Ruby30-x64/bin/irb.cmd:31:in 'load'
from C:/Ruby30-x64/bin/irb.cmd:31:in '<main>'
主要错误似乎是“找不到指定的模块”(这里是法语,抱歉)。我该如何解决这个问题?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。