【问题标题】:Requiring pry gem into ruby script causes error要求将 gem 撬入 ruby​​ 脚本会导致错误
【发布时间】:2019-04-23 17:58:16
【问题描述】:

我使用的是 ruby​​ 版本2.3.3p222

这是我的 Gemfile:

# Gemfile
source 'https://rubygems.org'

gem 'pry'

我运行bundle,这是生成的Gemfile.lock

Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    coderay (1.1.2)
    method_source (0.9.2)
    pry (0.12.2)
      coderay (~> 1.1.0)
      method_source (~> 0.9.0)

PLATFORMS
  ruby

DEPENDENCIES
  pry

BUNDLED WITH
   1.15.1

然后我只需通过ruby my_report.rb 运行一个ruby 脚本(此脚本与GemfileGemfile.lock 位于同一目录中)。 my_report.rb 文件中只有这个:

require 'pry'

这是错误:

WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-rescue-1.4.5/lib/pry-rescue.rb:15: warning: method BaseHelpers#windows? is deprecated. Use Pry:Helpers::Platform.windows? instead
/Users/<user>/.rvm/gems/ruby-2.3.3/gems/pry-stack_explorer-0.4.9.2/lib/pry-stack_explorer.rb:128:in `<top (required)>': undefined method `before_command' for #<Pry::CommandSet:0x007fccdcf0b1e8> (NoMethodError)

问题:我错过了什么?如何在我的 ruby​​ 脚本中正确要求 pry 以便设置断点?

【问题讨论】:

    标签: ruby pry


    【解决方案1】:

    最终对我有用的是我刚刚卸载了我通过gem uninstall 安装的所有pry 版本。然后:在我的 gemfile 中,我指定了以前版本的 0.11.3

    # Gemfile
    source 'https://rubygems.org'
    gem 'pry', '0.11.3'
    

    我做了bundle install,然后运行了我的 ruby​​ 脚本,这对我有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-24
      • 2014-01-07
      • 1970-01-01
      • 2014-02-16
      • 1970-01-01
      • 2014-09-03
      • 2015-09-12
      • 1970-01-01
      相关资源
      最近更新 更多