简体   繁体   English

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

[英]Requiring pry gem into ruby script causes error

I am using ruby version 2.3.3p222 我使用的是ruby版本2.3.3p222

Here is my Gemfile: 这是我的Gemfile:

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

gem 'pry'

I run bundle and here is the resulting Gemfile.lock 我运行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

I then simply run a ruby script via ruby my_report.rb (this script is located in the same directory as Gemfile and Gemfile.lock ). 然后,我只需通过ruby my_report.rb运行ruby脚本(此脚本与GemfileGemfile.lock位于同一目录中)。 my_report.rb only has this in the file: my_report.rb只在文件中有这个:

require 'pry'

Here is the error: 这是错误:

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)

Question: What am I missing? 问题:我错过了什么? How can I properly require in pry into my ruby script so that I can set breakpoints? 我如何正确地要求pry入我的ruby脚本以便我可以设置断点?

What eventually worked for me is I just uninstalled all of the pry versions I had installed via gem uninstall . 最终对我有用的是我刚刚卸载了我通过gem uninstall安装的所有pry版本。 Then: in my gemfile I specified a previous version of 0.11.3 : 然后:在我的gemfile中我指定了以前版本的0.11.3

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

I did bundle install and then ran my ruby script, and that worked for me. 我做了bundle install ,然后运行我的ruby脚本,这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM