From 095b5bbcc168f324588d42d4ef233b446ed9f860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Sun, 25 Jul 2021 16:10:55 +0200 Subject: [PATCH] [rubygems/rubygems] Lazily load shellwords https://github.com/rubygems/rubygems/commit/ef6388656a --- lib/bundler/cli/open.rb | 3 +-- lib/bundler/installer/gem_installer.rb | 3 +-- lib/bundler/rubygems_gem_installer.rb | 6 +++++- lib/bundler/source/git/git_proxy.rb | 3 +-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb index df32e2f38b..ea504344f3 100644 --- a/lib/bundler/cli/open.rb +++ b/lib/bundler/cli/open.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "shellwords" - module Bundler class CLI::Open attr_reader :options, :name @@ -19,6 +17,7 @@ module Bundler else path = spec.full_gem_path Dir.chdir(path) do + require "shellwords" command = Shellwords.split(editor) + [path] Bundler.with_original_env do system(*command) diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb index 10b7f6ce04..1df86ccfbc 100644 --- a/lib/bundler/installer/gem_installer.rb +++ b/lib/bundler/installer/gem_installer.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "shellwords" - module Bundler class GemInstaller attr_reader :spec, :standalone, :worker, :force, :installer @@ -47,6 +45,7 @@ module Bundler def spec_settings # Fetch the build settings, if there are any if settings = Bundler.settings["build.#{spec.name}"] + require "shellwords" Shellwords.shellsplit(settings) end end diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb index f5f3c53309..8890582318 100644 --- a/lib/bundler/rubygems_gem_installer.rb +++ b/lib/bundler/rubygems_gem_installer.rb @@ -61,7 +61,10 @@ module Bundler def build_extensions extension_cache_path = options[:bundler_extension_cache_path] - return super unless extension_cache_path && extension_dir = spec.extension_dir + unless extension_cache_path && extension_dir = spec.extension_dir + require "shellwords" # compensate missing require in rubygems before version 3.2.25 + return super + end extension_dir = Pathname.new(extension_dir) build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?) @@ -71,6 +74,7 @@ module Bundler FileUtils.cp_r extension_cache_path, spec.extension_dir end else + require "shellwords" # compensate missing require in rubygems before version 3.2.25 super if extension_dir.directory? # not made for gems without extensions SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index ae21770306..7555561edd 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "shellwords" - module Bundler class Source class Git @@ -224,6 +222,7 @@ module Bundler end def check_allowed(command) + require "shellwords" command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri) raise GitNotAllowedError.new(command_with_no_credentials) unless allow? command_with_no_credentials