From 6add9ceeee6040ba144079faf6245cc8513f9de9 Mon Sep 17 00:00:00 2001 From: Anthony ROUSSEL Date: Sun, 28 Jul 2024 16:32:12 +0200 Subject: [PATCH] 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. --- .../0004-delete-binstub-lock-file.patch | 36 +++++++++++++++++++ .../interpreters/ruby/rubygems/default.nix | 1 + 2 files changed, 37 insertions(+) create mode 100644 pkgs/development/interpreters/ruby/rubygems/0004-delete-binstub-lock-file.patch diff --git a/pkgs/development/interpreters/ruby/rubygems/0004-delete-binstub-lock-file.patch b/pkgs/development/interpreters/ruby/rubygems/0004-delete-binstub-lock-file.patch new file mode 100644 index 000000000000..91f221e19680 --- /dev/null +++ b/pkgs/development/interpreters/ruby/rubygems/0004-delete-binstub-lock-file.patch @@ -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 diff --git a/pkgs/development/interpreters/ruby/rubygems/default.nix b/pkgs/development/interpreters/ruby/rubygems/default.nix index 962fddf51b54..9fbfdb59fb07 100644 --- a/pkgs/development/interpreters/ruby/rubygems/default.nix +++ b/pkgs/development/interpreters/ruby/rubygems/default.nix @@ -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 = ''