要求pry gem进入ruby脚本会导致错误

问题描述 投票:0回答:1

我正在使用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)

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

ruby pry
1个回答
0
投票

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

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

我做了bundle install,然后运行我的红宝石脚本,这对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.