ruby.rubygems: fix delete binstub lock files

Fixes bug introduced with https://github.com/rubygems/rubygems/pull/7797

Binstub lock files are not deleted once the binstub is created,
and this breaks some build like mastodon.
This commit is contained in:
Anthony ROUSSEL 2024-07-28 16:32:12 +02:00
parent 257e0b2ac1
commit 6add9ceeee
No known key found for this signature in database
GPG Key ID: 9DC4987B1A55E75E
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,36 @@
A change introduced in PR https://github.com/rubygems/rubygems/pull/7797
does not delete the binstub lock files after the binstub file is created.
This change was introduced in rubygems 3.5.15,
and this version causes Hydra builds to fail, in particular mastodon.
A resolution is delete these binstub lock files after the binstub file is created
to prevent lock files from ending up in the bin folders of the various derivations
which will cause the build to fail.
---
diff --git a/bundler/lib/bundler/rubygems_ext.rb b/bundler/lib/bundler/rubygems_ext.rb
index 503959bba7..603b30e277 100644
--- a/bundler/lib/bundler/rubygems_ext.rb
+++ b/bundler/lib/bundler/rubygems_ext.rb
@@ -47,6 +47,8 @@ def self.open_file_with_flock(path, &block)
else
File.open(path, flags, &block)
end
+ ensure
+ FileUtils.rm_f(path) if File.exist?(path)
end
end
end
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index 569041f3d7..bcc95ae85c 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -796,6 +796,8 @@ def self.open_file_with_flock(path, &block)
else
open_file(path, flags, &block)
end
+ ensure
+ FileUtils.rm_f(path) if File.exist?(path)
end
end

View File

@ -18,6 +18,7 @@ stdenv.mkDerivation rec {
./0001-add-post-extract-hook.patch
./0002-binaries-with-env-shebang.patch
./0003-gem-install-default-to-user.patch
./0004-delete-binstub-lock-file.patch
];
installPhase = ''