diff --git a/lib/gdk/diagnostic/ruby_gems.rb b/lib/gdk/diagnostic/ruby_gems.rb index 796ea88ffce722bd68ae8e9a5d0a8460e5bb2d79..4c8daef3e2b365a8ec217dd12443f654662873de 100644 --- a/lib/gdk/diagnostic/ruby_gems.rb +++ b/lib/gdk/diagnostic/ruby_gems.rb @@ -50,7 +50,15 @@ def gem_installed?(name) end def gem_loads_ok?(name) - exec_cmd("#{bundle_exec_cmd} ruby -r #{name} -e 'nil'") + command = -> { exec_cmd("#{bundle_exec_cmd} ruby -r #{name} -e 'nil'") } + + if bundler_available? + ::Bundler.with_unbundled_env do + command.call + end + else + command.call + end end def exec_cmd(cmd) @@ -59,6 +67,10 @@ def exec_cmd(cmd) Shellout.new(cmd, chdir: config.gitlab.dir.to_s).execute(display_output: false, display_error: false).success? end + def bundler_available? + defined? ::Bundler + end + def gitlab_error_message <<~MESSAGE The following Ruby Gems appear to have issues: