-
-
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
[bug] require_relative
requires binary extention in unexpected location
#2300
Comments
@ojab Thanks for reporting this, and I'm sorry if you're having problems. Can you help me understand why "some people" are doing this? Specifically, is this officially recommended somewhere to maintain smaller install sizes? I do want to make sure Nokogiri is following best practices for C extensions, and I feel like I need to understand this a bit better. |
Ah, hmm, OK, I'm reading through the rubygems code and I'm just honestly confused why C extension files are being copied around to multiple places. But I agree the presence of |
…and I stopped writing reply after you reply 😄 |
@ojab Can you reply with the output from I'm inferring that you're not using the precompiled native gem, and I'm curious a) if that's true, and b) why you're choosing to compile rather than use the precompiled package? (Regardless, we should fix this, but I'm curious.) |
It's official ruby docker image (i. e. debian slimmed down a bit), nothing special:
Precompiled nokogiri also carries multiple copies of binary ext (just for different ruby versions). It's because of obsession with the docker image size, with single copy we're saving 4% of microservice space (final image is around 170 MB currently). |
@ojab OK, just wanted to verify that you're intentionally opting in to compiling during installation. If you wanted the best of both worlds (speed and size), you could delete the shared library files for versions of Ruby that you don't care about. In any case. #2301 is a PR that should fix this, going through CI now, and I'll release a patch version of v1.12 when it's green. |
Please describe the bug
In general binary extensions are residing in a separate directory that is added to
$LOAD_PATH
, so it works fine. But0cee8f0#diff-a610b0ddcdf14966b304b7f6ffc87a1c5866f232f995a0a27d1618b23658b12aR25 changed
require
(which searched this directory) torequire_relative
, which looks only ingems/nokogiri-*/lib/nokogiri
.Currently after build on ruby platform we have
so it works fine.
But for size-cutting some people are using
find ${LOCAL_BUNDLE_PATH}/gems/ -name '*.so' -delete
that removes seemingly excessive binary exts, after that we have.so
only inextension_dir
, sorequire_relative
fromgems/nokogiri-*/lib/nokogiri/extension.rb
fails, even though we have ext in$LOAD_PATH
.I can provide reproducer Dockerfile if needed and I can make a PR that reverts this particular
require_relative
if it's acceptable.Expected behavior
Nokogiri works fine when binary ext is removed from
gems
directory.Environment
Nokogiri (1.12.0) for
ruby
platform built for x86_86, docker image build fromruby:3.0.2-slim
withfind ${LOCAL_BUNDLE_PATH}/gems/ -name '*.so' -delete
after gems installation.The text was updated successfully, but these errors were encountered: