Skip to content

Commit f89cbca

Browse files
nobueregon
authored andcommitted
Fixed the location of the shared library
On platform where searchs shared libraries by `PATH` environment variable (i.e., Windows), the shared library is installed in `bindir`. On other platforms, the library directory is directed by `libdirname` indirectly.
1 parent a29152a commit f89cbca

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

library/rbconfig/rbconfig_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939

4040
guard -> {RbConfig::TOPDIR} do
4141
it "libdir/LIBRUBY_SO is the path to libruby and it exists if and only if ENABLE_SHARED" do
42-
libdir = RbConfig::CONFIG[RbConfig::CONFIG['libdirname'] || 'libdir']
42+
libdirname = RbConfig::CONFIG['LIBPATHENV'] == 'PATH' ? 'bindir' :
43+
RbConfig::CONFIG['libdirname']
44+
libdir = RbConfig::CONFIG[libdirname]
4345
libruby_so = "#{libdir}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
4446
case RbConfig::CONFIG['ENABLE_SHARED']
4547
when 'yes'

optional/capi/spec_helper.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ def compile_extension(name)
3232
ruby_header = "#{RbConfig::CONFIG['rubyhdrdir']}/ruby.h"
3333

3434
if RbConfig::CONFIG["ENABLE_SHARED"] == "yes"
35-
if PlatformGuard.windows?
36-
libruby_so = "#{RbConfig::CONFIG['bindir']}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
37-
else
38-
libruby_so = "#{RbConfig::CONFIG['libdir']}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
39-
end
35+
libdirname = RbConfig::CONFIG['LIBPATHENV'] == 'PATH' ? 'bindir' :
36+
RbConfig::CONFIG['libdirname'] # defined since 2.1
37+
libruby_so = "#{RbConfig::CONFIG[libdirname]}/#{RbConfig::CONFIG['LIBRUBY_SO']}"
4038
end
4139

4240
begin

0 commit comments

Comments
 (0)