Vagrant Rsync-auto Code Synchronization failure Error: Undefinedconversionerror

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.