-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
Ship precompiled gems for linux #1983
Comments
bundler-2.2.0 will fix the issues with binary gems. I already played a bit with it's improved multiplatform support on Windows. I didn't test nokogiri on Linux so far, but a nokogiri pre-release will allow easy testing. Regarding Alpine Linux (aka musl libc) I did some research and found out that After fixing the sprintf segfault, there is one failing test case on Alpine with binary gem:
The test case succeeds with |
we'll tackle linux native binaries soon in #1983
@larskanis Just want to confirm: you think I should ship an RC for precompiled linux? I can do that on Monday if so. I can add Alpine to the CI pipelines -- that might be the easiest way to tell if something's broken. I'll try to do that in the next day or so. |
@larskanis They're out there! https://twitter.com/flavorjones/status/1224334774753513473 |
Some feedback on precompiled binaries in general, not nokogiri per say. On paper precompiled binaries are great as they are much faster to install, however they are a huge pain whenever a new Ruby version is released. I just had this issue with the For instance https://rubygems.org/gems/nokogiri/versions/1.11.0.rc1-x86-linux has:
So let's imagine I use that version in my app, and by the end of 2020 I try to test the Ruby 3 RCs (or the 3.0 release in January 2021). I won't be able to bundle again because of that ruby version requirement. In theory bundler could fallback to the source gem (https://rubygems.org/gems/nokogiri/versions/1.11.0.rc1), but there's only one global flag which isn't very practical. Aaron had the same problem with grpc: https://twitter.com/tenderlove/status/1222937689751605248 I realize this is more of a Bundler feedback than a nokogiri one, but my personal opinion is that bundler/rubygems/whatever would need to be improved before popular gems start pushing precompiled binaries. |
@casperisfine Thanks for the feedback. This should be addressed in Bundler 2.2, see rubygems/bundler#7522 (mentioned above) for more context. |
🤦♂ Sorry, I read the issue description way too quickly. Great to hear this soon won't be a problem anymore. |
Overall, the best way to install nokogiri on Fedora is via Nevertheless, the runtime dependency on |
The binary nokogiri gem built with rake-compiler-dock-1.0.0 segfaults on x86_64-linux-musl. This happens in: lib/nokogiri/xml/reader.rb:92:in `namespaces' It turned out that any calls to sprintf() with %-arguments fail. I did not dig deeper on assembly level, since this is the only use of sprintf in nokogiri. Moreover it can be replaced by calls to ruby string functions easily. Related to sparklemotion#1983
Musl doesn't recognize cp932 encoding. It also fails when used on the command line with iconv. For this test case cp932 can be replaced by Shift_JIS, which is identical for the characters in question and that is handled by musl. Error was: 1) Error: Nokogiri::HTML::TestDocumentEncoding#test_encoding_without_charset: ArgumentError: invalid byte sequence in UTF-8 /home/lars/comcard/nokogiri/test/html/test_document_encoding.rb:26:in `test_encoding_without_charset' Related to sparklemotion#1983
@voxik Thanks for your comments! Regarding Fedora installation instructions, can I ask you to send a PR on this file in the documentation repo? And -- you're right! We shouldn't have a runtime dependency on mini_portile2 for pre-built packages. I've opened #1991 to fix that in a future RC. |
Just starting to investigate things, but I'm seeing behavior which suggests that gem install is ignoring |
@lamont-granquist The behavior you describe is expected. |
Yeah, anyone know how to override the ruby_platform on a |
@lamont-granquist Try |
@lamont-granquist Can you help me understand why you'd want to use the |
Thanks for the tip on the command. We build and ship our own precompiled ruby in a nonstandard location and use fixed rpaths in the binary (we also build libxml2 + libxslt and accept that we're entirely responsible for the CVEs in those and have to be responsive to that). In addition our libruby links against our own version of several other libraries like openssl (more fun CVEs) and libz and if anything that tries to link against libruby winds up linking against the system versions that can cause linker issues and hard failures. And the system versions we have to consider go back to RHEL6 for Linux and also include Solaris 11, AIX, FreeBSD and Mac -- our ruby version stays up-to-date so that we can ship e.g. ruby 2.7.0 on RHEL6 consistently and have up-to-date libz/openssl/etc (and then don't have to debug segfaults that have been fixed 6+ years ago in ruby core which still exist on RHEL6). We have a health check script which audits everything lib that goes into our build and spits out a list of violations. For this current prerelease of nokogiri the relevant bits of the report looks like:
So libz is considered "unsafe" because it needs to be picked up from the version in I think the TL;DR is that we're like the 0.0001% use case here. You might find though that you get bug reports from Chef users that attempt to upgrade the nokogiri version in their Chef packages themselves I suppose. The point of my doing this in our client builds is so that they don't have to, but people get stuck on old client versions, and may try to upgrade themselves. I don't see any easy way around that this morning though (inherently if they're on 5+ year old versions of the client I can't patch anything to make their life any easier, and it seems like the fat linux gem approach is vastly better for the 99% use case so those people are just going to need to be told to override the platform -- or just upgrade chef). We've been shipping prebuilt nokogiri for years now, so hopefully not many people are doing it themselves. |
@lamont-granquist Wow, thanks for that context, I appreciate the level of care you're putting into your environments. Are you able to work around bundler's behavior of (by default) installing native gems? You may find it helpful to set the bundler config key for |
That may come in helpful later. For the client nokogiri is a tacked on extra which we 'gem install'. The bundler tweaks may come in useful though for Chef Workstation (ChefDK) where nokogiri is used by the software we ship so its in the bundle we generate. That's just not the task today and I haven't even thought about that much yet. Yeah, looks like we |
@lamont-granquist to be clear, Nokogiri's "system libraries" flags still work, but only during installation of the
or the equivalent:
That command will work with past and future Nokogiri releases to compile nokogiri from source against local system libraries. |
Yep, already done it, which fixed builds. Backcompat seems to work as expected. |
To understand better, how does the precompiled nokogiri gem work on Alpine which uses musl? For context, the sassc gem also had precompiled Linux gems, but they were removed due to this musl/glibc mismatch in sass/sassc-ruby#145, which unfortunately makes it a very slow gem to install: sass/sassc-ruby#189 |
@flavorjones Thanks for the link, but my question was more about how does the nokogiri binary gem work on Alpine, since I assume it was precompiled against glibc? Does it statically include glibc? My understanding is using a binary compiled against glibc on alpine doesn't work without installing an extra |
Musl doesn't recognize cp932 encoding. It also fails when used on the command line with iconv. For this test case cp932 can be replaced by Shift_JIS, which is identical for the characters in question and that is handled by musl. Error was: 1) Error: Nokogiri::HTML::TestDocumentEncoding#test_encoding_without_charset: ArgumentError: invalid byte sequence in UTF-8 /home/lars/comcard/nokogiri/test/html/test_document_encoding.rb:26:in `test_encoding_without_charset' Related to #1983
The binary nokogiri gem built with rake-compiler-dock-1.0.0 segfaults on x86_64-linux-musl. This happens in: lib/nokogiri/xml/reader.rb:92:in `namespaces' It turned out that any calls to sprintf() with %-arguments fail. I did not dig deeper on assembly level, since this is the only use of sprintf in nokogiri. Moreover it can be replaced by calls to ruby string functions easily. Related to #1983
@eregon As of right now, the code on (edited with updated CI URL) |
hi all, im novice in ruby and i start to install rails and i get very error,and need help.
A:/*\ /install_ruby/Ruby27-x64/bin/ruby.exe -I A:/\ */install_ruby/Ruby27-x64/lib/ruby/2.7.0 -r ./siteconf20200506-16216-1tc60ph.rb extconf.rb --use-system-libraries
pkg-config could not be used to find libxslt
pkg-config could not be used to find libexslt
ERROR: cannot discover where libxml2 is located on your system. please make sure Provided configuration options: To see why this extension failed to compile, please check the mkmf.log which can be found here: A:/*/install_ruby/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/nokogiri-1.10.9/mkmf.log extconf failed, exit code 1 Gem files will remain installed in A://install_ruby/Ruby27-x64/lib/ruby/gems/2.7.0/gems/nokogiri-1.10.9 for inspection. |
Closing this issue. RC3 should be out shortly, and I'm pointing people to #2075 to provide feedback. |
Hello! If you're arriving here to give feedback on the v1.11.0 Release Candidates, please make sure to:
Thanks so much for using Nokogiri and for giving us feedback on this experiment!
See #1571 for the PR from @larskanis that enables building precompiled libraries for linux.
This issue is for discussion on how to ship those precompiled libraries in a gem for linux users in a way that won't break the installation experience for people.
Some things that we'll need to figure out were mentioned in #1571 by @larskanis:
And he later mentioned:
Finally, I'd like for
VersionInfo
to contain some indication that the user is using precompiled libraries. A patch that worked at one point on the #1571 branch (but now needs to be rewritten) is:And tagging @tenderlove for visibility because he had some thoughts on the previous #1571 thread.
The text was updated successfully, but these errors were encountered: