Skip to content

Commit

Permalink
Fix loading Ruby's dll on RubyInstaller 3.1
Browse files Browse the repository at this point in the history
Use RbConfig::CONFIG['LIBRUBY_SO'] to find dll's path.
Fix #114

Signed-off-by: Takuro Ashie <[email protected]>
  • Loading branch information
ashie committed Jan 13, 2022
1 parent 7f7d25e commit 88fe48d
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/serverengine/winsock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module WinSock
require 'fiddle/import'
require 'fiddle/types'
require 'socket'
require 'rbconfig'

extend Fiddle::Importer

Expand Down Expand Up @@ -101,14 +102,7 @@ module RbWinSock
extern "int GetModuleFileNameA(int, char *, int)"
extern "int CloseHandle(int)"

ruby_bin_path_buf = Fiddle::Pointer.malloc(1000)
GetModuleFileNameA(0, ruby_bin_path_buf, ruby_bin_path_buf.size)

ruby_bin_path = ruby_bin_path_buf.to_s.gsub(/\\/, '/')
ruby_dll_paths = File.dirname(ruby_bin_path) + '/*msvcr*ruby*.dll'
ruby_dll_path = Dir.glob(ruby_dll_paths).first
dlload ruby_dll_path

dlload RbConfig::CONFIG['LIBRUBY_SO']
extern "int rb_w32_map_errno(int)"

def self.raise_last_error(name)
Expand Down

0 comments on commit 88fe48d

Please sign in to comment.