gpt4 book ai didi

rspec - 引起 “Error: can' t修改字符串的防护;暂时锁定”

转载 作者:行者123 更新时间:2023-12-03 11:42:25 28 4
gpt4 key购买 nike

在使用guard-rspec在Rails 4项目中运行guard时,在vim中打开/关闭文件时偶尔会看到以下错误。我试过升级/降级guard,guard-rspec,pry和其他没有运气的库。

  • ruby​​ 2.0.0p247(2013-06-27修订版41674)[x86_64-linux]
  • Bundler版本1.3.5
  • Guard版本2.1.1

  • 下面是我看到的每一次几次测试运行的堆栈跟踪:
    Error: can't modify string; temporarily locked
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:624:in `readline'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:624:in `block in readline'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:564:in `handle_read_errors'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:609:in `readline'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:384:in `retrieve_line'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:301:in `block in r'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:298:in `loop'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:298:in `r'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:276:in `re'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:254:in `rep'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:234:in `block (3 levels) in repl'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:232:in `loop'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:232:in `block (2 levels) in repl'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:231:in `catch'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:231:in `block in repl'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:230:in `catch'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_instance.rb:230:in `repl'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/pry-0.9.12.2/lib/pry/pry_class.rb:170:in `start'
    /home/charles/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/guard-2.1.1/lib/guard/interactor.rb:133:in `block in start'
    [1] Specs guard(main)>

    最佳答案

    rb-readline gem添加到我的Gemfile中似乎可以解决此问题。

    gem "rb-readline", "~> 0.5.0"

    我的猜测是Ruby 2.0.0-p247的rbenv编译版本存在readline问题,这说明了为什么在 pry_instance.rb:624:in 'readline'中发生错误。 rb-readline项目是readline库的纯ruby实现,似乎可以缓解此问题。

    可能存在涉及重新编译 ruby 的更好的解决方案,但我还没有找到。

    关于rspec - 引起 “Error: can' t修改字符串的防护;暂时锁定”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19496932/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com