sassc-ruby
sassc-ruby copied to clipboard
FFI::NotFoundError: Function 'libsass_version' not found when using nix
Looks like nix
won't build the libsass.bundle
correctly for some reason. Any ideas?
here's a full backtrace.
$ bundle exec rake graphql:introspection --trace 14:58:39 2019
rake aborted!
FFI::NotFoundError: Function 'libsass_version' not found in [/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/libsass.bundle]
/Users/michaelglass/.gem/ruby/2.5.0/gems/ffi-1.11.1/lib/ffi/library.rb:273:in `attach_function'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native.rb:37:in `attach_function'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native/native_context_api.rb:5:in `<module:Native>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native/native_context_api.rb:4:in `<module:SassC>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native/native_context_api.rb:3:in `<main>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native.rb:58:in `<module:Native>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native.rb:6:in `<module:SassC>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc/native.rb:5:in `<main>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-2.2.0/lib/sassc.rb:31:in `<main>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-rails-2.1.2/lib/sassc/rails.rb:5:in `<main>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `block in require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/michaelglass/.gem/ruby/2.5.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require_relative'
/Users/michaelglass/.gem/ruby/2.5.0/gems/sassc-rails-2.1.2/lib/sassc-rails.rb:3:in `<main>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:83:in `register'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
/Users/michaelglass/.gem/ruby/2.5.0/gems/bootsnap-1.4.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `block (2 levels) in require'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `each'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `block in require'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `each'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `require'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `require'
/Users/michaelglass/Documents/work/rails/config/application.rb:12:in `<top (required)>'
/Users/michaelglass/Documents/work/rails/Rakefile:6:in `require'
/Users/michaelglass/Documents/work/rails/Rakefile:6:in `<top (required)>'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:82:in `block in run'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/Users/michaelglass/.gem/ruby/2.5.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/Users/michaelglass/.gem/ruby/2.5.0/bin/rake:23:in `load'
/Users/michaelglass/.gem/ruby/2.5.0/bin/rake:23:in `<top (required)>'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:74:in `load'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:74:in `kernel_load'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/cli/exec.rb:28:in `run'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:424:in `exec'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:27:in `dispatch'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/cli.rb:18:in `start'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/exe/bundle:30:in `block in <top (required)>'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/site_ruby/2.5.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/nix/store/dlsp4m6g9cz69pbx1a9q27x9fnmyhgxk-ruby-2.5.3/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/exe/bundle:22:in `<top (required)>'
/Users/michaelglass/Documents/work/rails/bin/bundle:104:in `load'
/Users/michaelglass/Documents/work/rails/bin/bundle:104:in `<main>'
I have just seen the same thing from bundle exec rails db:migrate
, and I'm using nix as well.
Same here, also using nix on MacOS.
/nix/store/qfpfm422812i64v9iwh372w2rk051m34-ruby2.6.3-ffi-1.11.1/lib/ruby/gems/2.6.0/gems/ffi-1.11.1/lib/ffi/library.rb:273:
in `attach_function': Function 'libsass_version' not found in [
/nix/store/nm1v8gxk2whv6d9f3xp0awma6hii8b88-ruby2.6.3-sassc-2.2.1/lib/ruby/gems/2.6.0/gems/sassc-2.2.1/lib/sassc/libsass.bundle
] (FFI::NotFoundError)
I built the gem manually and compared to the bundle being used by nix, and there's clearly a problem in the compilation step:
❯ ls -l /nix/store/46v23jpkv1pvbycbgd3az8ab22kp1x92-ruby2.6.3-sassc-2.2.1/lib/ruby/gems/2.6.0/gems/sassc-2.2.1/lib/sassc/libsass.bundle lib/sassc/libsass.bundle
-r-xr-xr-x 1 jon wheel 4144 Dec 31 1969 /nix/store/46v23jpkv1pvbycbgd3az8ab22kp1x92-ruby2.6.3-sassc-2.2.1/lib/ruby/gems/2.6.0/gems/sassc-2.2.1/lib/sassc/libsass.bundle*
-rwxr-xr-x 1 jon staff 2274992 Sep 23 18:05 lib/sassc/libsass.bundle*
do other folks have the same issues when using bundix?
I've found the problem: libsass is being compiled with -flto
resulting in LLVM bitcode objects which can't be linked with the ld
provided by nix's clang. See:
➜ file bind.o
bind.o: LLVM bitcode, wrapper x86_64
If I change ext/extconf.rb
like:
-if enable_config('lto', true)
+if enable_config('lto', false)
then we get
➜ file bind.o
bind.o: Mach-O 64-bit object x86_64
and bundle exec rake test
passes.
I don't know why this isn't a problem on other platforms.
I don't have time to think about how to solve this properly right now, but hopefully this information helps someone else.
related upstream issue: https://github.com/NixOS/nixpkgs/issues/19098
Interesting datapoint: attempting to build 2.0.1
with nixpkgs 20.03 through bundix gives me invalid option: --disable-lto
current directory: /nix/store/5m94jgir8n6dyfany3fd2za0ivrlqnz2-ruby2.6.6-sassc-2.0.1/lib/ruby/gems/2.6.0/gems/sassc-2.0.1/ext
/nix/store/1r5m6mlqdkqnyqsx3pcqscj9l7jmrgxa-ruby-2.6.6/bin/ruby -I/nix/store/1r5m6mlqdkqnyqsx3pcqscj9l7jmrgxa-ruby-2.6.6/lib/ruby/2.6.0/rubygems -rrubygems /nix/store/cdl7n07gcfpzfm0j38ycrdqzajqncmsa-ruby2.6.6-rake-13.0.1/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=/nix/store/5m94jgir8n6dyfany3fd2za0ivrlqnz2-ruby2.6.6-sassc-2.0.1/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-17/2.6.0/sassc-2.0.1 RUBYLIBDIR\=/nix/store/5m94jgir8n6dyfany3fd2za0ivrlqnz2-ruby2.6.6-sassc-2.0.1/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-17/2.6.0/sassc-2.0.1 --disable-lto
invalid option: --disable-lto
Temporary workaround for those who can't wait for https://github.com/sass/sassc-ruby/pull/192 to show up in sassc and whatever packages you're using that depend on it. If you use bundler (not bundix) for gem management, you can run bundle config build.sassc --disable-lto
to get the compilation to pass when running bundle install
.
I had this error too, very grateful for the your workaround with the build flag 🙏 .
I thought I'd chime in and say that if you're using bundix you can pass the flag in buildFlags
like so:
rubyEnv = pkgs.bundlerEnv {
inherit ruby;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
gemConfig = pkgs.defaultGemConfig // {
sassc = attrs: { buildFlags = [ "--disable-lto" ]; };
};
};