Skip to content

Commit 15761f0

Browse files
hsbtclaude
andcommitted
Initialize the new gem's git repo without a subshell
`bundle gem` ran `git init` through a backtick subshell with POSIX shell quoting. On Windows the backtick invokes cmd.exe, which ignores the POSIX escaping, so a target path containing spaces was split and the repo was created in the wrong place. Spawn git directly with an argument array, matching the `git add` call below. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b07218d commit 15761f0

2 files changed

Lines changed: 1 addition & 4 deletions

File tree

‎lib/bundler/cli/gem.rb‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ def run
247247

248248
if use_git
249249
Bundler.ui.info "\nInitializing git repo in #{target}"
250-
require "shellwords"
251-
`git init #{target.to_s.shellescape}`
250+
IO.popen(["git", "init", target.to_s], &:read)
252251

253252
config[:git_default_branch] = File.read("#{target}/.git/HEAD").split("/").last.chomp
254253
end

‎spec/bundler/commands/newgem_spec.rb‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ def installed_go?
8888
end
8989

9090
it "properly initializes git repo" do
91-
skip "path with spaces needs special handling on Windows" if Gem.win_platform?
92-
9391
bundle "gem #{gem_name}", dir: bundled_app("path with spaces")
9492
expect(bundled_app("path with spaces/#{gem_name}/.git")).to exist
9593
end

0 commit comments

Comments
 (0)