Skip to content

Commit 03dfe05

Browse files
Fix incompatible encodings error
1 parent 5265e07 commit 03dfe05

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

bundler/spec/commands/install_spec.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,35 @@ def run
12181218
end
12191219
end
12201220

1221+
describe "when configured path is UTF-8 and a file inside a gem package too", rubygems: ">= 3.5.23" do
1222+
let(:app_path) do
1223+
path = tmp("♥")
1224+
FileUtils.mkdir_p(path)
1225+
path
1226+
end
1227+
1228+
let(:path) do
1229+
root.join("vendor/bundle")
1230+
end
1231+
1232+
before do
1233+
build_repo4 do
1234+
build_gem "mygem" do |s|
1235+
s.write "spec/fixtures/_posts/2016-04-01-错误.html"
1236+
end
1237+
end
1238+
end
1239+
1240+
it "works" do
1241+
bundle "config path #{app_path}/vendor/bundle", dir: app_path
1242+
1243+
install_gemfile app_path.join("Gemfile"),<<~G, dir: app_path
1244+
source "https://gem.repo4"
1245+
gem "mygem", "1.0"
1246+
G
1247+
end
1248+
end
1249+
12211250
context "after installing with --standalone" do
12221251
before do
12231252
install_gemfile <<-G

lib/rubygems/package.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
421421

422422
open_tar_gz io do |tar|
423423
tar.each do |entry|
424-
full_name = entry.full_name
424+
full_name = entry.full_name.force_encoding(Encoding::UTF_8)
425425
next unless File.fnmatch pattern, full_name, File::FNM_DOTMATCH
426426

427427
destination = install_location full_name, destination_dir

0 commit comments

Comments
 (0)