From eef382c921685f0b3f0422996df580f1b6235834 Mon Sep 17 00:00:00 2001 From: Ernie Miller Date: Fri, 12 May 2017 16:44:18 -0400 Subject: [PATCH] Remove unnecessary require_relative `require-relative` breaks Rubygems' ability to use the arch-specific directory in `extensions`. When building grpc extensions from source, we're left with a lot of intermediate object files and a duplicate shared object file as well. This space can be reclaimed by finding these object files inside the `gems` subdirectory of the installation location, while leaving the shared object file in the `extensions` subdirectory. See the comments at https://github.com/rubygems/rubygems/issues/926 for more on this behavior, which has been present in Rubygems for years. By using `require` instead, those of us who build from source can reclaim space consumed by duplicate and intermediate files, which amounts to a savings of 46MB (in a build of 1.3.2 on Alpine Linux). This is helpful when trying to minimize the size of a Docker image. I'm unclear on whether or not the reclaiming of this space can be automated as part of the build process. If so, it may be worth considering as a separate effort. --- src/ruby/lib/grpc/grpc.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb index f46710dc742..48f2a45d44f 100644 --- a/src/ruby/lib/grpc/grpc.rb +++ b/src/ruby/lib/grpc/grpc.rb @@ -34,6 +34,6 @@ begin if File.directory?(distrib_lib_dir) require_relative "#{distrib_lib_dir}/grpc_c" else - require_relative 'grpc_c' + require 'grpc/grpc_c' end end