Ruby - LoadError enc / trans / single_byte

I had a strange problem when using the ActiveRecord :: Store module in my Ruby on Rails application. As far as I understand, this module uses the "serialize" method under the hood, so it simply converts your data into yaml format using the built-in Ruby gem file.

It works fine most of the time, but sometimes I get 500 errors with the following message:

LoadError (cannot load such file -- enc/trans/single_byte): ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:27:in `write' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:27:in `end_document' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:27:in `visit_Psych_Nodes_Document' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:20:in `block in visit_Psych_Nodes_Stream' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:20:in `each' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/emitter.rb:20:in `visit_Psych_Nodes_Stream' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/visitor.rb:15:in `visit' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/visitors/visitor.rb:5:in `accept' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych/nodes/node.rb:46:in `yaml' ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/psych.rb:243:in `dump' 

As you can see, I am using rbenv and ruby ​​1.9.3-p286. My system is Ubuntu 11.10. The required file exists ~/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/i686-linux/enc/trans/single_byte.so . The same error I encountered with ruby ​​1.9.3-p194. And the strangest part of this problem is that this error occurs from time to time.

So maybe someone also ran into this problem and already found a solution? Or is it like a mistake in psychology, and I have to send it to her companion?

Thanks in advance for your help!

EDIT: The problem is not directly related to the psycho. This is a common problem with an unusual ruby ​​setting. See the accepted answer below for more details.

+6
source share
1 answer

Does this happen in the comfortable environment of your development environment? If so, I would think to run it under the pry-rescue Pry.rescue do … end block and scroll it where it is.

I suspect the difference in data. Are there any non-ASCII intentionally involved in this tree? You could hunt for something like this:

 ruby -e 'Dir["**/*.yml"].each{|e| File.read(e)[/[^\x0-\x7f]/] and puts e}' 

As you indicated below, the rbenv installation is shared with other users, so be sure to change the permissions for any changes:

  chmod a+r -R ~/.rbenv/ 

Or perhaps create a common group, for example src , and then:

  chgrp src ~/.rbenv && chmod g+r -R ~/.rbenv 
+1
source

All Articles