I have a problem loading a gem (pg, a postgreSQL API for ruby) i have installed for ruby on windows. It was successfully installed with gem install. I downloaded Strawberry perl for the libpq libs and headers required for the pg gem. I received the following successful output:
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed pg-1.2.3
Parsing documentation for pg-1.2.3
Installing ri documentation for pg-1.2.3
Done installing documentation for pg after 7 seconds
1 gem installed
If I run gem list I can see the gem is also installed along with other gems:
gem list
> pg (1.2.3)
However I am unable to load it using the require method. If I try to run a script containing require 'pg' I get the following error:
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-x 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 P:/Projekte/OPTIMA_910/Hydraulik/Scripts/pg_snippet.rb:2:in `<main>'
<internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': 126: The specified module could not be found. - 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 D:/Scripts/pg_snippet.rb:2: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 D:/Scripts/pg_snippet.rb:2:in `<main>'
Likewise I try to run it as a command on irb I get a slightly different output:
Traceback (most recent call last):
14: from C:/Ruby30-x64/bin/irb.cmd:31:in `<main>'
13: from C:/Ruby30-x64/bin/irb.cmd:31:in `load'
12: from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
11: from (irb):2:in `<main>'
10: from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:149:in `require'
9: from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `rescue in require'
8: from <internal:C:/Ruby30-x64/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:160:in `require'
7: from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:4:in `<top (required)>'
6: from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:26:in `rescue in <top (required)>'
5: from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/pg.rb:15:in `block in <top (required)>'
4: from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/singleton.rb:12:in `add_dll_directory'
3: from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/singleton.rb:12:in `new'
2: from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/dll_directory.rb:50:in `initialize'
1: from C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/ruby_installer/runtime/dll_directory.rb:83:in `add_dll_directory_winapi'
RubyInstaller::Runtime::DllDirectory::WinApiError (AddDllDirectory failed for C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/pg-1.2.3/lib/x64-mingw32)
irb(main):003:0> gem list
Traceback (most recent call last):
5: from C:/Ruby30-x64/bin/irb.cmd:31:in `<main>'
4: from C:/Ruby30-x64/bin/irb.cmd:31:in `load'
3: from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `<top (required)>'
2: from (irb):2:in `<main>'
1: from (irb):3:in `rescue in <main>'
NameError (undefined local variable or method `list' for main:Object)
irb(main):004:0> C:/Ruby30-x64/lib/ruby/3.0.0/reline/unicode.rb:124:in `calculate_width': undefined method `encode' for nil:NilClass (NoMethodError)
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/line_editor.rb:1314:in `calculate_width'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/line_editor.rb:126:in `check_multiline_prompt'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/line_editor.rb:365:in `rerender'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:248:in `block (3 levels) in inner_readline'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:246:in `each'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:246:in `block (2 levels) in inner_readline'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:330:in `block in read_io'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:284:in `loop'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:284:in `read_io'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:245:in `block in inner_readline'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:243:in `loop'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:243:in `inner_readline'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:175:in `readmultiline'
from C:/Ruby30-x64/lib/ruby/3.0.0/forwardable.rb:238:in `readmultiline'
from C:/Ruby30-x64/lib/ruby/3.0.0/forwardable.rb:238:in `readmultiline'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/input-method.rb:302:in `gets'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:519:in `block (2 levels) in eval_input'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:721:in `signal_status'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:518:in `block in eval_input'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/ruby-lex.rb:202:in `lex'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/ruby-lex.rb:174:in `block (2 levels) in each_top_level_statement'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/ruby-lex.rb:171:in `loop'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/ruby-lex.rb:171:in `block in each_top_level_statement'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/ruby-lex.rb:170:in `catch'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb/ruby-lex.rb:170:in `each_top_level_statement'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:537:in `eval_input'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:472:in `block in run'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:471:in `catch'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:471:in `run'
from C:/Ruby30-x64/lib/ruby/3.0.0/irb.rb:400:in `start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/irb-1.3.0/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>'
I hope there is only some extra path I need to specify. I am also not using rails btw. Any help would be greatly appreciated! If anyone else has a good suggestion for an alternative for pg I might also be open to considering that.
Thanks in advance