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

Unable to load sassc-2.1.0.pre1 on Windows #125

Closed
ashmaroli opened this issue May 24, 2019 · 17 comments
Closed

Unable to load sassc-2.1.0.pre1 on Windows #125

ashmaroli opened this issue May 24, 2019 · 17 comments

Comments

@ashmaroli
Copy link

Steps to reproduce issue on Windows:

  1. gem install sassc --pre
  2. Load IRB: irb
  3. Require SassC: require 'sassc'

Output

LoadError: Could not open library 'C:/Ruby2.4-x64/lib/ruby/gems/2.4.0/gems/sassc-2.1.0.pre1-x64-mingw32/lib/sassc/2.4/libsass.so': ☺
@ashmaroli
Copy link
Author

Apparently, its not just Windows. The following is from a Travis job log.:

LoadError:
  Could not open library '/home/travis/build/jekyll/jekyll-sass-converter/vendor/bundle/ruby/2.6.0/gems/sassc-2.1.0.pre1-x86_64-linux/lib/sassc/2.6/libsass.so': 
  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by 
  /home/travis/build/jekyll/jekyll-sass-converter/vendor/bundle/ruby/2.6.0/gems/sassc-2.1.0.pre1-x86_64-linux/lib/sassc/2.6/libsass.so)

@betesh
Copy link

betesh commented May 24, 2019

I haven't been able to test this yet, but googling led me to https://askubuntu.com/a/582910/149571, which recommends sudo apt-get install libstdc++6. Not sure what the windows equivalent is...

@ahorek
Copy link

ahorek commented May 24, 2019

No, libc has to be compiled statically. There is probably just a parameter that needs to be passed to libsass in extconf.rb

@betesh
Copy link

betesh commented May 28, 2019

@ahorek I don't quite understand your comment. Does this mean a new version of sassc-ruby needs to be released? How would I build this locally?

@ahorek
Copy link

ahorek commented May 28, 2019

Does this mean a new version of sassc-ruby needs to be released?

yes, but prerelease versions are for testing. Use a stable version for now.

How would I build this locally?

you can always build it directly from the github repository, the problem is only with precompiled versions, so this should work for you. Of course you shouldn't use a testing version in production.

Gemfile
gem 'sassc', git: "https://github.com/sass/sassc-ruby.git"

this PR does what I meant, take a look #127 it should be fixed soon

@glebm
Copy link
Contributor

glebm commented Jun 4, 2019

This is fixed by #127

@bolandrm
Copy link
Member

bolandrm commented Jun 5, 2019

Version 2.1.0.pre2 released. Please give it a test!

@ashmaroli
Copy link
Author

@bolandrm Gem was successfully loaded and tested on both Travis CI and AppVeyor CI.

@betesh
Copy link

betesh commented Jun 5, 2019

#127 solved this issue for me, but after upgrading from there to 2.1.0.pre2, I get this error again:

LoadError: Could not open library
'/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so'
: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so)

with this stacktrace:

uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/ffi/library.rb:114:in `block in ffi_lib'
org/jruby/RubyArray.java:2487:in `map'
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/ffi/library.rb:84:in `ffi_lib'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/native.rb:10:in `<module:Native>'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/native.rb:6:in `<module:SassC>'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/native.rb:5:in `<main>'
org/jruby/RubyKernel.java:956:in `require'
uri:classloader:/jruby/kernel/kernel.rb:1:in `(root)'
uri:classloader:/jruby/kernel/kernel.rb:13:in `<main>'
org/jruby/RubyKernel.java:956:in `require'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc.rb:31:in `<main>'
org/jruby/RubyKernel.java:956:in `require'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-rails-2.1.1/lib/sassc/rails.rb:1:in `(root)'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-rails-2.1.1/lib/sassc/rails.rb:5:in `<main>'

This is on a Centos 7 docker image. The bundle install right before it works fine.

UPDATE:
Pulling from github instead of using the published gem fixes this. I made this change in Gemfile:

-  gem "sassc", "~> 2.1.0.pre2"
+  gem "sassc", github: 'sass/sassc-ruby'

Here's my Gemfile.lock, just so it's clear what commit it's using:

+GIT
+  remote: https://github.com/sass/sassc-ruby.git
+  revision: 105d691c2463835800f7bc899489da2ff53bd33b
+  specs:
+    sassc (2.1.0.pre2)
+      ffi (~> 1.9)
+

https://github.com/sass/sassc-ruby/releases/tag/v2.1.0.pre2 shows that the SHA in my Gemfile.lock (105d691) is the one released as v2.1.0.pre2.

So the code is capable of doing what it should, but something is different when using the published gem.

@glebm
Copy link
Contributor

glebm commented Jun 6, 2019

@betesh That's strange. Looking at libsass.so in the published precompiled gem (https://rubygems.org/gems/sassc/versions/2.1.0.pre2-x86_64-linux), I can see that libstdc++ is linked statically as expected:

$ ldd ~/tmp/libsass.so 
	linux-vdso.so.1 (0x00007ffc3195b000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb371dc3000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb371bd8000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fb3724be000)

The bundle install right before it works fine.

Does it install the precompiled version?
What's the output of ldd '/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so'?

@betesh
Copy link

betesh commented Jun 6, 2019

Does it install the precompiled version?

It's nested in platforms :jruby do. Does that answer the question? How else would I check?

What's the output of ldd '/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so'?

[root@875acd391e4e /]# ldd '/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so'
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so)
/root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /root/my_app/vendor/bundle/jruby/2.3.0/gems/sassc-2.1.0.pre2/lib/sassc/libsass.so)
	linux-vdso.so.1 =>  (0x00007ffd61f9b000)
	libc.so.6 => /lib64/libc.so.6 (0x00007face8272000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007face7f6b000)
	libm.so.6 => /lib64/libm.so.6 (0x00007face7c69000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007face7a53000)
	/lib64/ld-linux-x86-64.so.2 (0x00007face8b47000)

@glebm
Copy link
Contributor

glebm commented Jun 6, 2019

@betesh I've just realized that JRuby won't installed precompiled gems for "x86_64-linux", because its RUBY_PLATFORM is "Java", so for JRuby it's compiled from source on install.

Something is wrong in your CentOS container (or possibly but unlikely, the JRuby extconf code). It manages to compile the library with a version of libstdc++ that it then cannot find at runtime. Are you running bundle install within the container itself? You always should, because compiled gems cannot just be copied over and expected to work (when compiled, they use and target the shared libraries from the current system; you can, however, pass --with-static-stdlib to link stdlib statically).

If you must build the gem outside of the container, configure bundler to link the libraries statically like this:

bundle config --local build.sassc --with-static-stdlib

@betesh
Copy link

betesh commented Jun 6, 2019

Are you running bundle install within the container itself?

I was, but only after running it from the host, so when I ran it on the container, it was already installed. That fixed it, thank you!

@glebm
Copy link
Contributor

glebm commented Jun 6, 2019

@betesh Here is an example Dockerfile and docker-compose.yml that makes this mistake impossible:

https://github.com/thredded/thredded/blob/master/docker-compose.yml
https://github.com/thredded/thredded/blob/master/Dockerfile

The idea here is to never mount .bundle into the container, so that it always has its own. For an application, you'll also want to COPY Gemfile.lock (not mounted in the example because it's from a library).

@glebm
Copy link
Contributor

glebm commented Jun 10, 2019

@bolandrm Everything looks good, I think 2.1.0 can be finally released! 😄 :shipit:

@DirtyF
Copy link

DirtyF commented Aug 12, 2019

@bolandrm Anything preventing 🚢?

@bolandrm
Copy link
Member

2.1.0 released!

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