'Ruby 2.3: time_zone.rb:272: warning: circular argument reference - now

As part of upgrading a Dockerfile I'm trying to make a specific gem run that contains guides written some 8+ years ago.

I have found out I have to use Ruby <= 2.3 for it because above that it gives endless syntax errors most probably because of some major changes in 2.4.

I'm installing Ruby 2.3.8 with rvm this way:

# Install libssl-1.0 from 'stretch' repositories (needed for ruby 2.3)
RUN echo "deb http://deb.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list.d/libssl-legacy.lenter code hereist \
 && echo "deb-src http://deb.debian.org/debian stretch main contrib non-free" >> /etc/apt/sources.list.d/libssl-legacy.list \
 && echo "APT::Default-Release "bullseye";" > /etc/apt/apt.conf.d/libssl-legacy \
 && apt update && apt install -y libssl1.0-dev

# Install Ruby 2.3 with RVM (to /usr/local/rvm/rubies/ruby-2.3.8/bin/ruby)
ENV PATH="/usr/local/rvm/bin:$PATH"
ENV rvm_path="/usr/local/rvm"
RUN curl -sSL https://rvm.io/mpapis.asc | gpg2 --import - \
 && curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import - \
 && curl -sSL https://get.rvm.io | bash \
 && rvm install 2.3

A few days ago I managed to make this guide build without a problem, but I can't seem to make it work now. What am I missing?

I get the following error while trying to build the gem with 'guides build':

/usr/local/rvm/gems/ruby-2.3.8/gems/activesupport3.0.20/lib/active_support/values/time_zone.rb:272: warning: circular argument reference - now

It points to this function in time_zone.rb:

 # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from parsed string. Example:
#
#   Time.zone = "Hawaii"                      # => "Hawaii"
#   Time.zone.parse('1999-12-31 14:00:00')    # => Fri, 31 Dec 1999 14:00:00 HST -10:00
#
# If upper components are missing from the string, they are supplied from TimeZone#now:
#
#   Time.zone.now                 # => Fri, 31 Dec 1999 14:00:00 HST -10:00
#   Time.zone.parse('22:30:00')   # => Fri, 31 Dec 1999 22:30:00 HST -10:00
def parse(str, now=now)
  date_parts = Date._parse(str)
  return if date_parts.blank?
  time = Time.parse(str, now) rescue DateTime.parse(str)
  if date_parts[:offset].nil?
    ActiveSupport::TimeWithZone.new(nil, self, time)
  else
    time.in_time_zone(self)
  end
end

ruby -v:

ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]

gem -v:

3.3.10

bundler -v:

Bundler version 2.3.10


Solution 1:[1]

def parse(str, now=now) <- here is your issue.

you are trying to set now to itself. A circular argument reference means that a variable is looking for itself.

/active_support/values/time_zone.rb:272:: warning: circular argument reference

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 R.J. Robinson