summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authordan <i@dan.games>2025-11-13 16:55:18 +0800
committerLudovic Courtès <ludo@gnu.org>2025-11-13 21:51:59 +0100
commitca7de586054f7f3899b66fc8ba59d0bf6ab5b7db (patch)
treecfc3f753f8ac6740b62c7aa6489dc14845acdb8e /gnu
parent2f4ca85ee38e767a124993838b31ac4539532c18 (diff)
gnu: ruby-activesupport: Fix build.
* 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 <ludo@gnu.org>
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/patches/ruby-activesupport-fix-deprecation-warning.patch126
-rw-r--r--gnu/packages/rails.scm7
3 files changed, 133 insertions, 1 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 1c05902b2a5..f33e7090277 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 00000000000..376de727726
--- /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 <john@hawthorn.email>
+Date: Tue, 5 Nov 2024 19:36:51 -0800
+Subject: [PATCH] Fix deprecation warning caused by DST
+
+Co-authored-by: Matthew Draper <matthew@trebex.net>
+---
+ .../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 219ba5f010f..583c8bdc4bb 100644
--- a/gnu/packages/rails.scm
+++ b/gnu/packages/rails.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2019, 2021, 2022 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2019 Christopher Baines <mail@cbaines.net>
;;; Copyright © 2023 Maxim Cournoyer <maxim@guixotic.coop>
+;;; Copyright © 2025 dan <i@dan.games>
;;;
;;; 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