From ca7de586054f7f3899b66fc8ba59d0bf6ab5b7db Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 13 Nov 2025 16:55:18 +0800 Subject: [PATCH] gnu: ruby-activesupport: Fix build. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/patches/ruby-activesupport-fix-deprecation-warning.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/rails.scm (ruby-activesupport): Apply it. Change-Id: Ibeafb74ae93a42108ea5f383996756c43b0bc444 Signed-off-by: Ludovic Courtès --- gnu/local.mk | 1 + ...ctivesupport-fix-deprecation-warning.patch | 126 ++++++++++++++++++ gnu/packages/rails.scm | 7 +- 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/ruby-activesupport-fix-deprecation-warning.patch diff --git a/gnu/local.mk b/gnu/local.mk index 1c05902b2a5b32f870c37b23de57b588a2bbd801..f33e7090277704ac5e6eb56e2899f3cfbe94fd38 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2247,6 +2247,7 @@ dist_patch_DATA = \ %D%/packages/patches/rocm-opencl-runtime-4.3-noclinfo.patch \ %D%/packages/patches/rottlog-direntry.patch \ %D%/packages/patches/ruby-actionpack-remove-browser-tests.patch \ + %D%/packages/patches/ruby-activesupport-fix-deprecation-warning.patch \ %D%/packages/patches/ruby-asciidoctor-pdf-support-prawn-svg-0_36.patch \ %D%/packages/patches/ruby-chunky-png-ruby-3-2-support.patch \ %D%/packages/patches/ruby-hiredis-use-system-hiredis.patch \ diff --git a/gnu/packages/patches/ruby-activesupport-fix-deprecation-warning.patch b/gnu/packages/patches/ruby-activesupport-fix-deprecation-warning.patch new file mode 100644 index 0000000000000000000000000000000000000000..376de7277268fbbf04a815e86cf51ecf5ec58d78 --- /dev/null +++ b/gnu/packages/patches/ruby-activesupport-fix-deprecation-warning.patch @@ -0,0 +1,126 @@ +Upstream-status: https://github.com/rails/rails/pull/53546 +From df6585664d3dc2b1314a1a3a3933e128ef3653c8 Mon Sep 17 00:00:00 2001 +From: John Hawthorn +Date: Tue, 5 Nov 2024 19:36:51 -0800 +Subject: [PATCH] Fix deprecation warning caused by DST + +Co-authored-by: Matthew Draper +--- + .../core_ext/time/compatibility.rb | 10 +++- + .../date_and_time_compatibility_test.rb | 58 ++++++++++++++++++- + 2 files changed, 66 insertions(+), 2 deletions(-) + +diff --git a/activesupport/lib/active_support/core_ext/time/compatibility.rb b/activesupport/lib/active_support/core_ext/time/compatibility.rb +index 76c346f949176..4e6c8ca3ca4dd 100644 +--- a/activesupport/lib/active_support/core_ext/time/compatibility.rb ++++ b/activesupport/lib/active_support/core_ext/time/compatibility.rb +@@ -15,10 +15,18 @@ def to_time + end + + def preserve_timezone # :nodoc: +- active_support_local_zone == zone || super ++ system_local_time? || super + end + + private ++ def system_local_time? ++ if ::Time.equal?(self.class) ++ zone = self.zone ++ String === zone && ++ (zone != "UTC" || active_support_local_zone == "UTC") ++ end ++ end ++ + @@active_support_local_tz = nil + + def active_support_local_zone +diff --git a/activesupport/test/core_ext/date_and_time_compatibility_test.rb b/activesupport/test/core_ext/date_and_time_compatibility_test.rb +index 0bde69d0ba9bf..d00f3ea34ec19 100644 +--- a/activesupport/test/core_ext/date_and_time_compatibility_test.rb ++++ b/activesupport/test/core_ext/date_and_time_compatibility_test.rb +@@ -12,6 +12,7 @@ def setup + @date_time = DateTime.new(2016, 4, 23, 14, 11, 12, 0) + @utc_offset = 3600 + @system_offset = -14400 ++ @system_dst_offset = -18000 + @zone = ActiveSupport::TimeZone["London"] + end + +@@ -43,7 +44,7 @@ def test_time_to_time_does_not_preserve_time_zone + end + end + +- def test_time_to_time_without_preserve_configured ++ def test_time_to_time_on_utc_value_without_preserve_configured + with_preserve_timezone(nil) do + with_env_tz "US/Eastern" do + source = Time.new(2016, 4, 23, 15, 11, 12) +@@ -60,6 +61,24 @@ def test_time_to_time_without_preserve_configured + end + end + ++ with_preserve_timezone(nil) do ++ with_env_tz "US/Eastern" do ++ source = Time.new(2016, 11, 23, 15, 11, 12) ++ # No warning because it's already local ++ base_time = source.to_time ++ ++ utc_time = base_time.getutc ++ converted_time = assert_deprecated(ActiveSupport.deprecator) { utc_time.to_time } ++ ++ assert_equal source, base_time ++ assert_equal source, converted_time ++ assert_equal @system_dst_offset, base_time.utc_offset ++ assert_equal @system_dst_offset, converted_time.utc_offset ++ end ++ end ++ end ++ ++ def test_time_to_time_on_offset_value_without_preserve_configured + with_preserve_timezone(nil) do + with_env_tz "US/Eastern" do + foreign_time = Time.new(2016, 4, 23, 15, 11, 12, in: "-0700") +@@ -70,6 +89,43 @@ def test_time_to_time_without_preserve_configured + assert_not_equal foreign_time.utc_offset, converted_time.utc_offset + end + end ++ ++ with_preserve_timezone(nil) do ++ with_env_tz "US/Eastern" do ++ foreign_time = Time.new(2016, 11, 23, 15, 11, 12, in: "-0700") ++ converted_time = assert_deprecated(ActiveSupport.deprecator) { foreign_time.to_time } ++ ++ assert_equal foreign_time, converted_time ++ assert_equal @system_dst_offset, converted_time.utc_offset ++ assert_not_equal foreign_time.utc_offset, converted_time.utc_offset ++ end ++ end ++ end ++ ++ def test_time_to_time_on_tzinfo_value_without_preserve_configured ++ foreign_zone = ActiveSupport::TimeZone["America/Phoenix"] ++ ++ with_preserve_timezone(nil) do ++ with_env_tz "US/Eastern" do ++ foreign_time = foreign_zone.tzinfo.utc_to_local(Time.new(2016, 4, 23, 15, 11, 12, in: "-0700")) ++ converted_time = assert_deprecated(ActiveSupport.deprecator) { foreign_time.to_time } ++ ++ assert_equal foreign_time, converted_time ++ assert_equal @system_offset, converted_time.utc_offset ++ assert_not_equal foreign_time.utc_offset, converted_time.utc_offset ++ end ++ end ++ ++ with_preserve_timezone(nil) do ++ with_env_tz "US/Eastern" do ++ foreign_time = foreign_zone.tzinfo.utc_to_local(Time.new(2016, 11, 23, 15, 11, 12, in: "-0700")) ++ converted_time = assert_deprecated(ActiveSupport.deprecator) { foreign_time.to_time } ++ ++ assert_equal foreign_time, converted_time ++ assert_equal @system_dst_offset, converted_time.utc_offset ++ assert_not_equal foreign_time.utc_offset, converted_time.utc_offset ++ end ++ end + end + + def test_time_to_time_frozen_preserves_timezone diff --git a/gnu/packages/rails.scm b/gnu/packages/rails.scm index 219ba5f010ff1c29d2179bda1fbabcb8c085bb03..583c8bdc4bba1849c4c15c70c24b0335273ba291 100644 --- a/gnu/packages/rails.scm +++ b/gnu/packages/rails.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2019, 2021, 2022 Efraim Flashner ;;; Copyright © 2019 Christopher Baines ;;; Copyright © 2023 Maxim Cournoyer +;;; Copyright © 2025 dan ;;; ;;; This file is part of GNU Guix. ;;; @@ -57,7 +58,11 @@ (package (name "ruby-activesupport") (version %ruby-rails-version) - (source ruby-rails-monorepo) + (source + (origin + (inherit ruby-rails-monorepo) + ;; Remove this patch when upgrading rails to 7.2.3+. + (patches (search-patches "ruby-activesupport-fix-deprecation-warning.patch")))) (build-system ruby-build-system) (arguments (list