diff --git a/Library/Homebrew/test/unpack_strategy/tar_spec.rb b/Library/Homebrew/test/unpack_strategy/tar_spec.rb index 6e41d232ef..d47df7b76e 100644 --- a/Library/Homebrew/test/unpack_strategy/tar_spec.rb +++ b/Library/Homebrew/test/unpack_strategy/tar_spec.rb @@ -62,8 +62,8 @@ RSpec.describe UnpackStrategy::Tar do } end - it "uses a stable locale for tar diagnostics" do - expect(strategy).to receive(:system_command!).with("tar", hash_including(env: { "LC_ALL" => "C" })) + it "uses a UTF-8 locale for tar so non-ASCII paths can be extracted" do + expect(strategy).to receive(:system_command!).with("tar", hash_including(env: { "LC_ALL" => "en_US.UTF-8" })) strategy.extract(to: unpack_dir) end diff --git a/Library/Homebrew/unpack_strategy/tar.rb b/Library/Homebrew/unpack_strategy/tar.rb index 49b0abbc08..2d8f063704 100644 --- a/Library/Homebrew/unpack_strategy/tar.rb +++ b/Library/Homebrew/unpack_strategy/tar.rb @@ -52,9 +52,10 @@ module UnpackStrategy args: ["--extract", "--no-same-owner", "--file", tar_path, "--directory", unpack_dir], - # Keep tar diagnostics in English so that out of space error handle in - # `‎unpack_strategy.rb` can recognize out-of-space errors. - env: { "LC_ALL" => "C" }, + # Keep tar diagnostics in English so that `unpack_strategy.rb` can + # recognize out-of-space errors, while using a UTF-8 character set so + # that archives containing non-ASCII paths can be extracted. + env: { "LC_ALL" => "en_US.UTF-8" }, verbose: end end