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

3

22

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)>
Dhyana answered 21/10, 2013 at 14:13 Comment(1)
I'm experiencing exactly same thing. I'm on RVM (1.24.4). And ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]. And pry 0.9.14. And Rails 3.2.14. And Ubuntu 13.10.Braasch
D
15

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.

Dhyana answered 21/10, 2013 at 21:24 Comment(2)
Don't know about you, but using rb-readline completely screws up my pry environment (i.e. executing binding.pry while running specs), so it's a no go.Braasch
@PawełGościcki Me too. There are other side effects with using rb-readline that I've noticed. Such as the home and end keys not working as expected.Dhyana
G
3

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.

Grig answered 15/11, 2013 at 11:49 Comment(4)
I'm not sure that's the case. I'm using Ruby 2.0.0p353 (2013-11-22 revision 43784) and I still experience it.Braasch
Same problem with 2.1.0p0Delbert
Yup I see this with 2.1.0p0 too.Jape
Anyone get past this on 2.1.0p0?Blythe
O
0

are you using Sublime Text 3? If yes, you should definitely check this out!

TLDR: Set "atomic_save": false.

Orthoepy answered 5/3, 2014 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.