Skip to content

Commit

Permalink
Workaround "-b" problem of Bundler by monkey-patching Bundler::Shared…
Browse files Browse the repository at this point in the history
…Helpers.clean_load_path: Fix #861

Bundler has had a problem in running with JRuby.
See rubygems/bundler#4565 for the details.
  • Loading branch information
dmikurube committed Nov 30, 2017
1 parent ec21be9 commit 71f5a61
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,28 @@ private void setBundlerPluginSourceDirectory(final ScriptingContainer jruby, fin
jruby.runScriptlet("Gem.clear_paths");
jruby.runScriptlet("require 'bundler'");

// TODO: Remove the monkey patch once the issue is fixed on Bundler or JRuby side.
// @see <a href="https://github.com/bundler/bundler/issues/4565">Bundler::SharedHelpers.clean_load_path does cleanup the default load_path on jruby - Issue #4565 - bundler/bundler</a>
final String monkeyPatchOnSharedHelpersCleanLoadPath =
"begin\n" +
" require 'bundler/shared_helpers'\n" +
" module Bundler\n" +
" module DisableCleanLoadPath\n" +
" def clean_load_path\n" +
" # Do nothing.\n" +
" end\n" +
" end\n" +
" module SharedHelpers\n" +
" def included(bundler)\n" +
" bundler.send :include, DisableCleanLoadPath\n" +
" end\n" +
" end\n" +
" end\n" +
"rescue LoadError\n" +
" # Ignore LoadError.\n" +
"end\n";
jruby.runScriptlet(monkeyPatchOnSharedHelpersCleanLoadPath);

jruby.runScriptlet("Bundler.load.setup_environment");
jruby.runScriptlet("require 'bundler/setup'");
// since here, `require` may load files of different (newer) embulk versions
Expand Down

0 comments on commit 71f5a61

Please sign in to comment.