导致“ ArgumentError:非绝对首页”的“ binding.pry”

时间:2019-06-04 20:52:30

标签: ruby pry

在什么情况下pry会因此错误而失败?

sort()

故障点代码:

ArgumentError: non-absolute home

堆栈跟踪:

puts "ENV['HOME']: #{ENV['HOME']}"
binding.pry

更新

我发现,如果我在模块顶部ENV['HOME']: localhost:3000 rake aborted! ArgumentError: non-absolute home /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:105:in `expand_path' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:105:in `real_path_to' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:100:in `block in rc_files_to_load' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:100:in `map' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:100:in `rc_files_to_load' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:88:in `load_rc_files' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:148:in `initial_session_setup' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/pry_class.rb:184:in `start' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/pry-0.12.2/lib/pry/core_extensions.rb:43:in `pry' /Users/bart_simpson/Projects/kewl_project/kewl_project/lib/tasks/kewl_project_tasks_helper.rb:104:in `block in import_energy_storage_facilities_from_state_task2' /Users/bart_simpson/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/csv.rb:1764:in `each' /Users/bart_simpson/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/csv.rb:1142:in `block in foreach' /Users/bart_simpson/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/csv.rb:1289:in `open' /Users/bart_simpson/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/csv.rb:1141:in `foreach' /Users/bart_simpson/Projects/kewl_project/kewl_project/lib/tasks/kewl_project_tasks_helper.rb:100:in `import_energy_storage_facilities_from_state_task2' /Users/bart_simpson/Projects/kewl_project/kewl_project/lib/tasks/kewl_project_tasks_helper.rb:69:in `import_energy_storage_facilities_via_state_task' /Users/bart_simpson/Projects/kewl_project/kewl_project/lib/tasks/kewl_project.rake:215:in `block (2 levels) in <main>' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/task.rb:273:in `block in execute' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/task.rb:273:in `each' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/task.rb:273:in `execute' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/task.rb:214:in `block in invoke_with_call_chain' /Users/bart_simpson/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/task.rb:194:in `invoke_with_call_chain' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/task.rb:183:in `invoke' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:160:in `invoke_task' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:116:in `block (2 levels) in top_level' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:116:in `each' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:116:in `block in top_level' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:125:in `run_with_threads' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:110:in `top_level' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:83:in `block in run' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:186:in `standard_exception_handling' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/lib/rake/application.rb:80:in `run' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/gems/rake-12.3.2/exe/rake:27:in `<top (required)>' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/bin/rake:23:in `load' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/bin/rake:23:in `<main>' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/bin/ruby_executable_hooks:24:in `eval' /Users/bart_simpson/.rvm/gems/ruby-2.5.1@kewl_project/bin/ruby_executable_hooks:24:in `<main>' Tasks: TOP => kewl_project:import_energy_storage_facilities 之后立即发出binding.pry(即不在某个方法内,但在任何方法范围之外),则它起作用并且require 'pry'为我们期望的是:

ENV['HOME']

所以现在的问题是:/Users/bart_simpson 在哪里变成ENV['HOME']

1 个答案:

答案 0 :(得分:0)

ENV['HOME']被覆盖。

有人在我们的应用程序环境变量中添加了ENV['HOME']='localhost:3000'。不好!<​​/ p>

很抱歉浪费了每个人的时间!