The ruby sassc
gem bundles libsass
as a C library and uses the ffi
gem to talk to its bundled compiled version. When I build the gem, it spends a while building native extensions, but the end result is completely unusable. Trying to load the sassc
gem fails with a stack trace that ends in the error
FFI::NotFoundError (Function 'libsass_version' not found in [/nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/libsass.bundle])
(that referenced bundle file contains no symbols beyond dyld_stub_binder
so I don’t know what’s going on there)
I saw this with a bundlerApp
package but I can trivially reproduce this with the following line:
nix run '(with import <nixpkgs> {}; ruby.withPackages (ps: [ ps.sassc ]))' -c ruby -r sassc -e ''
Full output
Traceback (most recent call last):
1: from /nix/store/9lywmsbfjcwjgdfvp6p9whx8gl3hyf71-ruby-2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/nix/store/9lywmsbfjcwjgdfvp6p9whx8gl3hyf71-ruby-2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- sassc (LoadError)
13: from /nix/store/9lywmsbfjcwjgdfvp6p9whx8gl3hyf71-ruby-2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
12: from /nix/store/9lywmsbfjcwjgdfvp6p9whx8gl3hyf71-ruby-2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
11: from /nix/store/9lywmsbfjcwjgdfvp6p9whx8gl3hyf71-ruby-2.6.4/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
10: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc.rb:31:in `<top (required)>'
9: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc.rb:31:in `require_relative'
8: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb:5:in `<top (required)>'
7: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb:6:in `<module:SassC>'
6: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb:58:in `<module:Native>'
5: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb:58:in `require_relative'
4: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native/native_context_api.rb:3:in `<top (required)>'
3: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native/native_context_api.rb:4:in `<module:SassC>'
2: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native/native_context_api.rb:5:in `<module:Native>'
1: from /nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/native.rb:37:in `attach_function'
/nix/store/08x36k91iyvclxbm3yradcm8d1lsybyi-ruby2.6.4-ffi-1.10.0/lib/ruby/gems/2.6.0/gems/ffi-1.10.0/lib/ffi/library.rb:273:in `attach_function': Function 'libsass_version' not found in [/nix/store/x9x15c391y1kmzrcfi75llwlrbdhra2q-ruby2.6.4-sassc-2.2.0/lib/ruby/gems/2.6.0/gems/sassc-2.2.0/lib/sassc/libsass.bundle] (FFI::NotFoundError)
On the other hand, if I use bundler
directly in a test, everything works fine.
> cat Gemfile
source 'https://rubygems.org' do
gem 'sassc'
end
> bundler i --path vendor
[…output…]
> ruby -r bundler/setup -r sassc -e 'print SassC::VERSION'
2.2.0
In this situation vendor/ruby/2.6.0/gems/sassc-2.2.0/lib/sassc/libsass.bundle
contains the full expected set of symbols.
Does anyone know what’s going on here? This is on macOS, if that makes a difference.