Ruby 2.3:time_zone.rb:272:警告:循环参数引用 - 现在

发布于 2025-01-18 18:48:55 字数 2450 浏览 2 评论 0原文

作为升级Dockerfile的一部分,我试图制作一个特定的宝石跑步,其中包含大约8年前写的指南。

我发现我必须使用ruby< = 2.3,因为它在上面给出了无尽的语法错误,这很可能是因为某些 2.4 的重大变化。

”安装Ruby 2.3.8

# 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

我正在使用

我在尝试使用“指南构建”构建宝石时会遇到以下错误:

/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

它在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:bundler -v:

3.3.10

bundler -v:

Bundler version 2.3.10

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹂绝世的画 2025-01-25 18:48:55

DEF PARSE(str,现在=现在)&lt ;--这是您的问题。

您正在尝试现在设置为自己。循环参数参考意味着变量正在寻找自身。

/active_support/values/time_zone.rb:272 ::警告:循环参数参考

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文