(PE-31696) Prefer builtin lib code over external gems when autoloading #8685
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In PE we use the ruby interpreter shipped with puppet agent to run the ace server. The ace server is responsible for executing remote tasks. Remote tasks will often use the
puppet
library. Remote ruby tasks run in ace over the local transport (and thus bolt) execute code with the same environment variables as the ruby process running the task runner uses. In the case of ace, we ship a puppet gem in addition to many of the other gems bolt depends on. Now that puppet has moved to using require_relative there is a bug whereby a new combination of code is loaded between the puppet gem and the puppet code shipped with the agent (because we set GEM_HOME and GEM_PATH when we start the service). This commit updates the autoloader to prefer loading code from the $LOAD_PATH. This helps solve the problem of loading code from both places in ace-server for remote tasks. The only consequence it may have would be if users somehow relied on shadowing shipped puppet code with external gems, though it is hard to imagine how they would manage to reliably configure this.