Getting 'specififed module cannot be found' when requiring pg from Ruby 3.0

Viewed 122

I've installed the latest versions of Ruby and PostGre with their respective installers.

The exact versions are:

I've installed the PostGre gem with:

gem install pg -- --with-pg-dir="C:\path\to\PostGre" which installed the pg-1.2.3 gem successfully.

Yet when I do require 'pg' in IRB, I get an error message:

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>'

The main error seems to be the 'specified module cannot be found' (here in French, sorry). How can I fix this?

0 Answers
Related