From c0be0ecc53eda75ad50d7351e037a8a6ae3d1ef1 Mon Sep 17 00:00:00 2001 From: Kyle Benne Date: Fri, 5 Apr 2024 15:08:59 -0500 Subject: [PATCH] Add comment about loading Ruby Gems ref #5136 --- ruby/bindings/InitRubyBindings.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ruby/bindings/InitRubyBindings.cpp b/ruby/bindings/InitRubyBindings.cpp index 8de7af6c40..55b42d65ca 100644 --- a/ruby/bindings/InitRubyBindings.cpp +++ b/ruby/bindings/InitRubyBindings.cpp @@ -593,6 +593,19 @@ void setGemPathDir(const std::vector& gemPathDirs) { } void locateEmbeddedGems(bool use_bundler) { + // It is important to find, eval, and call add_spec for all of the gemspecs + // that are in the embedded file system. The rubgems find/load mechanims will + // attempt to use a number of Ruby file, directory, and path operations that + // are not compaitable with the embdded file system. By doing the find, eval, + // add_spec routine up front, rubygems will avoid trying to load things off of + // the embedded file system itself. + // + // A previous version of this routine added embedded file paths to the gem + // path, such as Gem.paths.path << ':/ruby/3.2.0/gems/'. This is not + // sustainable because it requires shims for many of the Ruby file operations + // so that they work with embedded files. The solution here avoids File + // operations on embdded file system with the exception of our own + // EmbeddedScripting::getFileAsString std::string initCmd = R"ruby( Gem::Deprecate.skip = true