【问题标题】:Ruby undefined method error using Deprecate.skip_during使用 Deprecate.skip_during 的 Ruby 未定义方法错误
【发布时间】:2011-09-23 08:10:27
【问题描述】:

我正在尝试在我的本地计算机上安装 Gitorious。但是,当我执行控制台应用程序时出现此错误:

/usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb:194:in block in stub_source_index170': undefined methodskip_during' 为 Bundler::RubygemsIntegration::Deprecate:Class (NoMethodError)

在 /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/rubygems_integration.rb 中执行的 ruby​​ 代码是:

def stub_source_index170(specs)
      Gem::SourceIndex.send(:define_method, :initialize) do |*args|
        @gems = {}
        # You're looking at this thinking: Oh! This is how I make those
        # rubygems deprecations go away!
        #
        # You'd be correct BUT using of this method in production code
        # must be approved by the rubygems team itself!
        #
        # This is your warning. If you use this and don't have approval
        # we can't protect you.
        #
        Deprecate.skip_during do
          self.spec_dirs = *args
          add_specs(*specs)
        end
      end
    end

我猜这个错误是因为没有加载过时的模块或类似的东西...我不知道 ruby​​...但是我该如何尝试纠正它?

我有 ruby​​ 1.9.1p431(2011-02-18 修订版 30908)和 gem 1.8.5

宝石列表:

* 本地宝石 *

actionmailer (2.3.5) 动作包 (2.3.5) 活动记录 (2.3.8, 2.3.5) 主动资源(2.3.5)主动支持 (2.3.8, 2.3.5) 充当可标记 (2.0.6) 构建器 (3.0.0) 捆绑器 (1.0.15) 慢性 (0.3.0) daemon_controller (0.2.6) 守护进程 (1.1.0) diff-lcs (1.1.2) 回声 (4.3.1) 事件机(0.12.10) 异常通知(1.0.20090728) factory_girl (1.3.3) 快速线程 (1.0.7)gemcutter(0.6.1)geoip (0.8.9) 锄头 (2.8.0) json_pure (1.5.0) 哑剧类型(1.16)摩卡(0.9.10)mysql (2.8.1) oauth (0.4.4) 回形针 (2.2.9.2) 乘客 (3.0.7) proxymachine (1.2.4) 机架 (1.0.1) rails (2.3.5) rake (0.8.7) rdiscount (1.3.1.1) revo-ssl_requirement (1.1.0) 谜语 (1.2.2) rmagick (2.13.1) ruby-hmac (0.4.0) ruby​​-openid (2.1.8) ruby-yadis (0.3.4) ruby​​forge (2.0.4) 应该 (2.9.2) state_machine (0.9.4) stomp (1.1) stompserver (0.9.9) tuxml (0.0.1) validates_url_format_of (0.1.1) will_paginate (2.3.15)

非常感谢。

卡洛斯。

【问题讨论】:

    标签: ruby module gem


    【解决方案1】:

    较新版本的 Rubygems 正在弃用一些旧的内部方法。您可以使用 gem update --system 1.x.y(例如 1.5.2)降级 Rubygems 以查看是否可以解决您的问题。

    【讨论】:

    • 您好,感谢您的回答。我是 Ruby 的新手。降级系统会影响安装的gem吗?谢谢?
    • 不,它应该不会影响已安装的 gem。
    【解决方案2】:

    Deprecate 被命名为 Gem::Deprecate。您可以临时修补它:

    Gem::Deprecate.skip_during do
      self.spec_dirs = *args
      add_specs(*specs)
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-10
      • 1970-01-01
      相关资源
      最近更新 更多