Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guard causing "Error: can't modify string; temporarily locked"

Tags:

rspec

rbenv

guard

When running guard in a Rails 4 project with guard-rspec, I sporadically see the following error when opening/closing files in vim. I've tried upgrading/downgrading guard, guard-rspec, pry, and other libraries without luck.

  • ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
  • Bundler version 1.3.5
  • Guard version 2.1.1

Below is the stacktrace I see every few test runs:

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)>
like image 576
Charles Maresh Avatar asked Oct 21 '13 14:10

Charles Maresh


2 Answers

Adding the rb-readline gem to my Gemfile seems to fix the issue.

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

My guess is the rbenv compiled version of Ruby 2.0.0-p247 has readline issues, which explains why the error occurs in pry_instance.rb:624:in 'readline'. The rb-readline project is a pure ruby implementation of the readline library and seems to alleviate the issue.

There may be a better solution involving recompiling ruby, but I haven't found it.

like image 63
Charles Maresh Avatar answered Nov 17 '22 01:11

Charles Maresh


It seems to be an error in Ruby 2.0.0 and 1.9.3 indeed. See https://bugs.ruby-lang.org/issues/8669

Its backported to Ruby 2.0.0 in revision 42216.

like image 24
dan Avatar answered Nov 17 '22 00:11

dan