Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.0 compile error #141

Closed
navied opened this issue Aug 19, 2019 · 15 comments
Closed

2.1.0 compile error #141

navied opened this issue Aug 19, 2019 · 15 comments

Comments

@navied
Copy link

navied commented Aug 19, 2019

2.1.0 doesn't seem to be compile for me on alpine linux systems. It is failing with this error:

LoadError: Could not open library '/codebuild/output/src471049011/src/vendor/bundle/ruby/2.5.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/libsass.so': Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /codebuild/output/src471049011/src/vendor/bundle/ruby/2.5.0/gems/sassc-2.1.0-x86_64-linux/lib/sassc/libsass.so)

But it seems to compile fine on a OSX / Ubuntu system just fine though!

@firefart
Copy link

Getting the same error after upgrading to rails 6

@glebm
Copy link
Contributor

glebm commented Aug 20, 2019

On Alpine you need to install the libc6-compat package to use the pre-compiled gem.

@glebm
Copy link
Contributor

glebm commented Aug 20, 2019

Note also that this is not a compilation error: it's an error while loading the pre-compiled library. Alpine comes with musl instead of libc6 (which the pre-compiled libsass.so is linked against). If you install the gem from source on Alpine (gem install sassc --platform RUBY), libsass.so will be linked against musl.

@firefart
Copy link

firefart commented Aug 20, 2019

Sorry buy installing libc6-compat is no real option.

I am currently installing the gem from source with bundler (bundle install --system --clean --no-cache) in the ruby-aline image and it still uses the compiled version so I clearly consider this as a bug as it should compile the library during install.

PS: This happened during the upgrade to rails 6 and our Gemfile only contains a reference to 'sass-rails'

Here is an excepert of the bundle isntall:

Fetching ffi 1.11.1
Installing ffi 1.11.1 with native extensions
Fetching sassc 2.1.0 (x86_64-linux)
Installing sassc 2.1.0 (x86_64-linux)
Fetching sprockets 3.7.2
Installing sprockets 3.7.2
Fetching sprockets-rails 3.2.1
Installing sprockets-rails 3.2.1

Error message when running rake:

rake aborted!
LoadError: Could not open library '/usr/local/bundle/gems/sassc-2.1.0-x86_64-linux/lib/sassc/libsass.so': Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/local/bundle/gems/sassc-2.1.0-x86_64-linux/lib/sassc/libsass.so)
/usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:145:in `block in ffi_lib'
/usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:99:in `map'
/usr/local/bundle/gems/ffi-1.11.1/lib/ffi/library.rb:99:in `ffi_lib'
/usr/local/bundle/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb:10:in `<module:Native>'
/usr/local/bundle/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb:6:in `<module:SassC>'
/usr/local/bundle/gems/sassc-2.1.0-x86_64-linux/lib/sassc/native.rb:5:in `<main>'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `require_relative'
/usr/local/bundle/gems/sassc-2.1.0-x86_64-linux/lib/sassc.rb:31:in `<main>'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
/usr/local/bundle/gems/sassc-rails-2.1.2/lib/sassc/rails.rb:5:in `<main>'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `block in require'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:291:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:325:in `require'
/usr/local/bundle/gems/sass-rails-6.0.0/lib/sass-rails.rb:1:in `<main>'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/usr/local/bundle/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:76:in `each'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:76:in `block in require'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:65:in `each'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/runtime.rb:65:in `require'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler.rb:114:in `require'
/app/config/application.rb:9:in `<top (required)>'
/app/Rakefile:6:in `require'
/app/Rakefile:6:in `<top (required)>'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/rake_module.rb:29:in `load_rakefile'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:703:in `raw_load_rakefile'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:104:in `block in load_rakefile'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:103:in `load_rakefile'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:82:in `block in run'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/local/bundle/gems/rake-12.3.3/lib/rake/application.rb:80:in `run'
/usr/local/bundle/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:23:in `load'
/usr/local/bundle/bin/rake:23:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `load'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/cli/exec.rb:28:in `run'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/cli.rb:465:in `exec'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/cli.rb:27:in `dispatch'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/cli.rb:18:in `start'
/usr/local/bundle/gems/bundler-2.0.2/exe/bundle:30:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.0.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.0.2/exe/bundle:22:in `<top (required)>'
/usr/local/bundle/bin/bundle:23:in `load'
/usr/local/bundle/bin/bundle:23:in `<main>'

@glebm
Copy link
Contributor

glebm commented Aug 20, 2019

I am currently installing the gem from source

No, the following line means you're installing the pre-compiled version:

Installing sassc 2.1.0 (x86_64-linux)

Here is how you can force bundler to avoid pre-compiled gems:

bundle config force_ruby_platform true

(This has the same effect as setting BUNDLE_FORCE_RUBY_PLATFORM=true env var).

Run this in your Alpine container before running bundle install.

ledermann added a commit to ledermann/docker-rails that referenced this issue Aug 20, 2019
Because we use the Alpine image, the native extension must be compiled from source

sass/sassc-ruby#141 (comment)
@firefart
Copy link

Thanks the bundle config worked!
Maybe this should be mentioned in the Readme too so other people can spot this easiliy?

@glebm
Copy link
Contributor

glebm commented Aug 21, 2019

By the way, this is something you should always do if you're using Alpine. It's not specific to this gem at all.

How did you decide to use Alpine? It's designed for power users (https://alpinelinux.org/about/) who understand all the implications of using a non-libc environment. There are small Debian containers as well, such as Minideb, though still much larger than Alpine.

@firefart
Copy link

It's not about not understanding Alpine linux, it's about a not properly documented flag in bundler. Nothing in the docs hints at this and honestly I've never seen it before.
Take the nokogiri and ffi gems for example. Both build on install with native extensions without using this flag, but this gem doesn't. We've ran the images for years now without problems but the recent updates from rails introduced these problems (maybe they were always there but the libraries were linked statical).
But all after all this now works

@glebm
Copy link
Contributor

glebm commented Aug 21, 2019

Nokogiri and ffi don't have pre-compiled gems for Linux, that's why they are always compiled from source on install on Linux.

Rails 6.0 depends on a newer version of sass-rails which depends on sassc v2.1.0+. If you're seeing this for the first time, it's only because none of the other dependencies in your application provide precompiled gems for Linux.

libc6 should not be linked statically (and basically never is).

@alexwlchan
Copy link

Just to note:

I ran into this problem when I upgraded to Jekyll 4, which I run in a Docker container with an Alpine base image.

Adding BUNDLE_FORCE_RUBY_PLATFORM=true to my Docker image seems to have done the trick, but I got a segfault first (alexwlchan/alexwlchan.net#286), and it took a while to realise that Alpine was the culprit.

@bolandrm
Copy link
Member

@glebm Should we perhaps stop shipping a precompiled gem for linux? We've got a few different issues at this point, and I'm not sure how to debug them. These issues didn't really come up previously.

@L1Cafe
Copy link

L1Cafe commented Aug 27, 2019

@glebm Should we perhaps stop shipping a precompiled gem for linux? We've got a few different issues at this point, and I'm not sure how to debug them. These issues didn't really come up previously.

I think my issue #144 is also related to this one. The Jekyll Docker image is indeed based off Alpine: https://github.com/envygeeks/jekyll-docker#packages. Will try the bundle config trick now

@glebm
Copy link
Contributor

glebm commented Aug 27, 2019

Should we perhaps stop shipping a precompiled gem for linux?

@bolandrm Yes, I think we should. It's unfortunate that RubyGems doesn't let us to target a particular version of libc and users don't seem to be aware of this distinction because other popular gems don't ship precompiled Linux versions.

glebm added a commit to glebm/sassc-ruby that referenced this issue Aug 27, 2019
We can't target a particular libc with RubyGems and many users aren't aware of this (sass#141).
@bolandrm
Copy link
Member

2.2.0 release with no precompiled linux gem. Please give that a shot.

@L1Cafe
Copy link

L1Cafe commented Aug 27, 2019

Thanks @glebm! It now works on my Alpine Docker machine without the bundle config setting. Thanks for the fast response.

thibaudgg added a commit to csa-admin-org/csa-admin that referenced this issue Apr 5, 2020
scouillard added a commit to scouillard/bbb-demo that referenced this issue Feb 7, 2022
Try to specify postgres-alpine version.
Bug/issue with Alpine and the sassc-ruby gems (as per sass/sassc-ruby#141).
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

No branches or pull requests

6 participants