"接着"从eval(...)调用binding.pry时不起作用

时间:2017-02-15 13:35:45

标签: ruby debugging eval pry

当我使用eval()运行binding.pry脚本时,我看到了这个错误:

  

错误:无法找到本地上下文。您使用的是binding.pry吗?

test.rb:

require 'pry'

def a
  binding.pry
  puts 'Hello'
end

a

runner.rb:

script = File.read('test.rb')
eval script

输出:

$ ruby runner.rb   
[1] pry(main)> next 
Error: Cannot find local context. Did you use `binding.pry`?
[2] pry(main)> continue 
Error: Cannot find local context. Did you use `binding.pry`?
[3] pry(main)>

我需要从脚本调用binding.pry,但我无法编辑runner.rb

$ gem list
...
pry (0.10.4)
pry-byebug (3.4.2)
...

$ ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

0 个答案:

没有答案