Today using vagrant, code synchronization: Vagrant Rsync-auto found that the code synchronization is invalid, a few restarts after the discovery of an error:
A bit puzzled, because the 1h also synchronized with the modified code, now suddenly error, the current still unknown reason (this 1h has not done any coding settings/modifications of the operation, still weird, left to the great God Research Bar ~) The following direct focus
reasons for the error :
Vagrant Source code using Ruby implementation, Ruby Transcoding method: Encode transcoding compatible, GBK transcoding for UTF-8 incompatible, so error, error line source code:
Data << io.readpartial (read_chunk_size). Encode ("UTF-8", encoding.default_external)
Workaround :
Idea: Use the Force_encoding method to convert the parameters to UTF-8 encoding.
Method: Find the Error directory: C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.7.2\lib\vagrant\util io.rb file Find line 32, change the code to:
Data << io.readpartial (read_chunk_size). force_encoding (' UTF-8 ')
Then vagrant reload no error, restart success, code synchronization success. This is a bug in vagrant.
To talk about the twists and turns in the process, after the first discovery of this error, I will mistake: "From GBK to UTF-8" is understood as:
To transcode to UTF-8 must require the original code is GBK, so I changed the io.rb in the wrong source into this way:
str = io.readpartial (read_chunk_size). force_encoding (' GBK ')//cast to GBK
Data << str. Encode ("UTF-8", encoding.default_external)//convert GBK to UTF-8
This is still an error, and then I see the transcoding of the encode is encoded compatible, so the use of cast conversion to UTF-8, sure enough or simple rough better ~ ~
Enclosed: I am so happy to solve this problem, and a step closer to the great God.
Vagrant Rsync-auto Code Synchronization failure Error: Undefinedconversionerror