Skip to content

Commit 9aa80cf

Browse files
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.
1 parent f05aa62 commit 9aa80cf

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

benchmarks/shipit/benchmark.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,25 @@
55
ENV['SHIPIT_DISABLE_AUTH'] = '1' # Saves us lots of trouble
66

77
Dir.chdir __dir__
8+
89
use_gemfile
910

11+
# sassc uses FFI with hardcoded paths to find its compiled libsass shared object.
12+
# RubyGems 4.x (Ruby 4.1+) no longer copies extensions into the gem's lib/ tree,
13+
# so sassc can't find it. Copy it into place.
14+
if RUBY_VERSION >= "4.1"
15+
spec = Gem::Specification.find_by_name("sassc") rescue nil
16+
if spec
17+
dl_ext = RbConfig::MAKEFILE_CONFIG['DLEXT']
18+
target = File.join(spec.gem_dir, "ext", "libsass.#{dl_ext}")
19+
source = File.join(spec.extension_dir, "sassc", "libsass.#{dl_ext}")
20+
if !File.exist?(target) && File.exist?(source)
21+
require 'fileutils'
22+
FileUtils.cp(source, target)
23+
end
24+
end
25+
end
26+
1027
require 'securerandom'
1128
ENV['SECRET_KEY_BASE'] = SecureRandom.hex(128)
1229

0 commit comments

Comments
 (0)