Skip to content

Fix sassc: copy libsass into ext dir when Ruby >= 4.1#477

Merged
eightbitraptor merged 1 commit intomainfrom
mvh-fix-shipit
Feb 17, 2026
Merged

Fix sassc: copy libsass into ext dir when Ruby >= 4.1#477
eightbitraptor merged 1 commit intomainfrom
mvh-fix-shipit

Conversation

@eightbitraptor
Copy link
Contributor

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.

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.
@k0kubun
Copy link
Member

k0kubun commented Feb 17, 2026

Does the shipit benchmark compile sass files? If it's loaded in Bundler.require and the loading itself is the only problem, can we add gem "sassc", require: false or something to skip loading the gem?

@eightbitraptor
Copy link
Contributor Author

I don't think that's going to be possible because the dependency chain that ends up requiring sassc is going through shipit-engine -> sass-rails -> sassc-rails -> sassc.

Shipit::Engine is mounted in the routes as part of the benchmark, so as soon as we require it we're going to end up pulling in sassc.

@eightbitraptor eightbitraptor merged commit a5998ba into main Feb 17, 2026
22 checks passed
@eightbitraptor eightbitraptor deleted the mvh-fix-shipit branch February 17, 2026 20:47
# 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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ideally check the rubygems version instead. It's possible to update rubygems for an older Ruby.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if RUBY_VERSION >= "4.1"
unless Gem.install_extension_in_lib

We may use Gem.install_extension_in_lib instead of version condition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments