From a926478f98f35c8185f6a32666fcbd60f7f6f73c Mon Sep 17 00:00:00 2001 From: Matt Smuts Date: Mon, 8 Jul 2024 12:31:36 +0100 Subject: [PATCH] Fix native library load error on AL2023 Update the paths FFI searches when loading libsass.so to include the gem extension path. Should allow use on Amazon Linux 2023. copied from https://github.com/sass/sassc-ruby/issues/146#issuecomment-2099259975 --- lib/sassc/native.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/sassc/native.rb b/lib/sassc/native.rb index 3b9f515f..38b4fda5 100644 --- a/lib/sassc/native.rb +++ b/lib/sassc/native.rb @@ -6,12 +6,13 @@ module SassC module Native extend FFI::Library - dl_ext = RbConfig::MAKEFILE_CONFIG['DLEXT'] - begin - ffi_lib File.expand_path("libsass.#{dl_ext}", __dir__) - rescue LoadError # Some non-rvm environments don't copy a shared object over to lib/sassc - ffi_lib File.expand_path("libsass.#{dl_ext}", "#{__dir__}/../../ext") + library = "libsass.#{RbConfig::MAKEFILE_CONFIG['DLEXT']}" + candidates = [__dir__, "#{__dir__}/../../ext"] + if Gem.loaded_specs['sassc'] + candidates.unshift(Gem.loaded_specs['sassc'].extension_dir) + candidates.unshift("#{Gem.loaded_specs['sassc'].extension_dir}/sassc") end + ffi_lib(candidates.map { |dir| File.expand_path(library, dir) }) require_relative "native/sass_value"