From 1655fd426a8b09faccd982f1c99730887204af12 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Fri, 11 Oct 2024 17:33:07 -0500 Subject: [PATCH] Add Ruby version Check (#298) * add check * Update xprof/xprof.rb.in Co-authored-by: Brice Videau --------- Co-authored-by: Thomas Applencourt Co-authored-by: Brice Videau --- xprof/xprof.rb.in | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xprof/xprof.rb.in b/xprof/xprof.rb.in index 64b2017d..22fca45f 100755 --- a/xprof/xprof.rb.in +++ b/xprof/xprof.rb.in @@ -1,5 +1,13 @@ #!/usr/bin/env ruby + +# 2.7 for Lazy in Enumerable. 2.7 was released 25 Dec 2019 +THAPI_RUBY_MINIMAL_VERSION = '2.6.0' +if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(THAPI_RUBY_MINIMAL_VERSION) + warn("Your ruby version #{RUBY_VERSION} is too old. #{THAPI_RUBY_MINIMAL_VERSION} or newer required") + exit(1) +end + # We Cannot use "@ .. @" for libdir, bindir, and dataroodir # as they will appear as bash "${exec_prefix}/lib" # So for now we will rely on them having the default value, @@ -226,7 +234,8 @@ def thapi_trace_dir_root # Use ISO8601 extended format date = DateTime.now.iso8601 - (0..).each do |i| + # Don't use endless range, as it trigger "syntax error" for ruby 2.5... + (0..Float::INFINITY).each do |i| prefix = i == 0 ? '' : "_#{i}" thapi_uuid = date + prefix path = File.join(thapi_trace_home, "thapi#{prefix_processed_trace}--#{thapi_uuid}")