我正在尝试调试一个简单的ruby控制台脚本,并在尝试要求pry时遇到加载错误:
/Users/gangelo/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in`requirement':无法加载此类文件 - 撬( LoadError)
过去我在rails应用程序中使用过Pry和Byebug,从来没有遇到过这样的问题。在搜索解决方案时,我发现大多数问题都与Gemfile中不包含Pry或者在Gem文件中的正确环境中不包含Pry gem有关;这不是我的情况,我做错了什么?
# /Gemfile
group :development, :test do
gem 'pry', '~> 0.10.4'
end
在我的剧本中:
# /calculator/rpn_calculator_service.rb
module RealPage
module Calculator
# Provides Reverse Polish Notation computation services.
class RPNCalculatorService < CalculatorService
include Helpers::Arrays
def initialize
super RPNInputParser.new
end
def compute(input)
# Load error here :(
require 'pry'; binding.pry
# Code removed for brevity...
end
# Code removed for brevity...
end
end
end
答案 0 :(得分:2)
我在尝试运行我的gem cars时遇到了类似的错误:
/Users/giovanni/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- pry (LoadError)
from /Users/giovanni/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/giovanni/.rvm/gems/ruby-2.2.3/gems/cars-0.0.6/bin/cars:3:in `<top (required)>'
from /Users/giovanni/.rvm/gems/ruby-2.2.3/bin/cars:23:in `load'
from /Users/giovanni/.rvm/gems/ruby-2.2.3/bin/cars:23:in `<main>'
from /Users/giovanni/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval'
from /Users/giovanni/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>'
我扣除了我的宝石可能没有安装,所以我跑了:
➜ ~ gem install pry
Fetching: coderay-1.1.2.gem (100%)
Successfully installed coderay-1.1.2
Fetching: method_source-0.9.0.gem (100%)
Successfully installed method_source-0.9.0
Fetching: pry-0.11.3.gem (100%)
Successfully installed pry-0.11.3
3 gems installed
然后像往常一样执行我的宝石