Skip to content

Commit

Permalink
Fix native library load error on AL2023
Browse files Browse the repository at this point in the history
Update the paths FFI searches when loading libsass.so to include the
gem extension path. Should allow use on Amazon Linux 2023. copied from
sass#146 (comment)
  • Loading branch information
fleetsource-matt committed Jul 8, 2024
1 parent 4fce2b6 commit a926478
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/sassc/native.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a926478

Please sign in to comment.