From 9aa80cf57f959441d8c1515ca920e5ab40be3a18 Mon Sep 17 00:00:00 2001 From: Matt Valentine-House Date: Tue, 17 Feb 2026 15:44:44 +0000 Subject: [PATCH] Fix sassc: copy libsass into ext dir when Ruby >= 4.1 RubyGems no longer copies compiled extensions into the gem's lib/ tree (ruby/rubygems@1614b036f7), breaking sassc which uses FFI with hardcoded paths. This commit copies libsass from the extensions directory into ext where sassc's native.rb expects it. Sassc is deprecated and publically archived anyway so there seems little point updating this upstream. I chose not to use Gem.configuration.install_extension_in_lib. Because it would set the behaviour for all gems in the bundle, and we'd still have to copy manually anyway, becuase the bundle isn't rebuilt between runs. --- benchmarks/shipit/benchmark.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/benchmarks/shipit/benchmark.rb b/benchmarks/shipit/benchmark.rb index 607498d0..72ad3404 100644 --- a/benchmarks/shipit/benchmark.rb +++ b/benchmarks/shipit/benchmark.rb @@ -5,8 +5,25 @@ ENV['SHIPIT_DISABLE_AUTH'] = '1' # Saves us lots of trouble Dir.chdir __dir__ + use_gemfile +# sassc uses FFI with hardcoded paths to find its compiled libsass shared object. +# RubyGems 4.x (Ruby 4.1+) no longer copies extensions into the gem's lib/ tree, +# so sassc can't find it. Copy it into place. +if RUBY_VERSION >= "4.1" + spec = Gem::Specification.find_by_name("sassc") rescue nil + if spec + dl_ext = RbConfig::MAKEFILE_CONFIG['DLEXT'] + target = File.join(spec.gem_dir, "ext", "libsass.#{dl_ext}") + source = File.join(spec.extension_dir, "sassc", "libsass.#{dl_ext}") + if !File.exist?(target) && File.exist?(source) + require 'fileutils' + FileUtils.cp(source, target) + end + end +end + require 'securerandom' ENV['SECRET_KEY_BASE'] = SecureRandom.hex(128)