uru auto cannot find non-ASCII .ruby-version files
I saw the similar bug reported. However I believe my case if different. I am on Windows 7 x64. Here is the powershell outputs:
#!
PS C:\Ruby\Uru> cat $env:USERPROFILE\.ruby-version
2.0.0p647
#!
PS C:\Ruby\Uru> uru auto
---> unable to find or process a `.ruby-version` file
#!
PS C:\Ruby\Uru> cat $env:USERPROFILE\.uru\rubies.json
{
"Version": "1.0.0",
"Rubies": {
"2700685649": {
"ID": "2.0.0-p647",
"TagLabel": "200p647",
"Exe": "ruby",
"Home": "C:\\Ruby\\RubyInstalls\\Ruby200-x64\\bin",
"GemHome": "",
"Description": "ruby 2.0.0p647 (2015-08-18) [x64-mingw32]"
}
}
}
Comments (3)
-
repo owner -
repo owner - changed title to uru auto cannot find non-ASCII .ruby-version files
-
assigned issue to
- marked as minor
-
repo owner I'm not happy with the current code for this one. For example, this code does a simple
string
conversion on the raw bytes read from.ruby-version
, e.g. -string(bytes.ToLower(bytes.Trim(b, " \r\n")))
, and directly uses the result to search against the tag labels (JSON persisted) of registered rubies.Since JSON can use unicode chars in strings, the current tag label fuzzy matching code likely falls down when one tags a ruby using non-ASCII unicode chars.
The current matching code needs reviewed and revised. Until I get back to this one, the safest workaround appears to be to use ASCII for both tag labels and the contents of
.ruby-version
. - Log in to comment
Good catch, thank you for reporting.
Uru
currently does not appear to handle.ruby-version
files that are not in ASCII. I'll look into this and look for a fix. The workaround is to delete your current$env:USERPROFILE\.ruby-version
file and recreate it in ASCII format. You can force Powershell to generate an ASCII.ruby-version
file by usingecho 225p235 | out-file -encoding ascii .ruby-version
At first I could not reproduce your error
I then deleted my
.ruby-version
file and created a new one via PowerShell. I was then able to reproduce your error.The problem was that Powershell created a non-ASCII version (UTF16) of
.ruby-version
as shown by this hex dump