Project

General

Profile

Bug #9737

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

Hi, 

 On Windows, if non-ASCII characters exist the path on which the ruby 
 interpreter is invoked, the character encoding is not handled properly 
 when the require paths in $: are created, making ruby unable to require 
 libraries in its standard lib paths. 

 In the first two examples, the working directory of the shell is not 
 a factor; what matters is the path by which the ruby interpreter is 
 invoked. 

 ~~~ 
 Here we invoke ruby using a path containing non-ASCII characters: 

 ~~~ 
 $ M:\dev\ruby-build\zz-können2\bin\ruby.exe -v --disable-gems -e "p $:.first.encoding, $:.first; require 'uri'" 
 ruby 2.2.0dev (2014-04-12 trunk 45576) [i386-mswin32_100] 
 #<Encoding:ASCII-8BIT> 
 "M:/dev/ruby-build/zz-k\xF6nnen2/lib/ruby/site_ruby/2.2.0" 
 -e:1:in `require': cannot load such file -- uri (LoadError) 
         from -e:1:in `<main>' 
 ~~~ 

 Here we invoke ruby in the same location, but instead using the 
 NTFS "short" name on the path so that it is ASCII only: 

 ~~~ 
 $ M:\dev\ruby-build\ZZ-KNN~2\bin\ruby.exe -v --disable-gems -e "p $:.first.encoding, $:.first; require 'uri'" 
 ruby 2.2.0dev (2014-04-12 trunk 45576) [i386-mswin32_100] 
 #<Encoding:IBM437> 
 "M:/dev/ruby-build/ZZ-KNN~2/lib/ruby/site_ruby/2.2.0" 
 ~~~ 

 In the second two examples, we change the working dir instead of 
 specifying the interpreter path directly.    The results are the same: 

 ~~~ 
 # working dir: M:\dev\ruby-build\zz-können2\bin 
 $ .\ruby.exe -v --disable-gems -e "p $:.first.encoding, $:.first; require 'uri'" 
 ruby 2.2.0dev (2014-04-12 trunk 45576) [i386-mswin32_100] 
 #<Encoding:ASCII-8BIT> 
 "M:/dev/ruby-build/zz-k\xF6nnen2/lib/ruby/site_ruby/2.2.0" 
 -e:1:in `require': cannot load such file -- uri (LoadError) 
         from -e:1:in `<main>' 

 # working dir: M:\dev\ruby-build\ZZ-KNN~2\bin 
 $ .\ruby.exe -v --disable-gems -e "p $:.first.encoding, $:.first; require 'uri'" 
 ruby 2.2.0dev (2014-04-12 trunk 45576) [i386-mswin32_100] 
 #<Encoding:IBM437> 
 "M:/dev/ruby-build/ZZ-KNN~2/lib/ruby/site_ruby/2.2.0" 
 ~~~ 


 I'm guessing this will be related to the `GetModuleFileName()` GetModuleFileName() call in: 

 ~~~ 
 win32/stub.c:      lenexe = (size_t)GetModuleFileName(NULL, exename, sizeof exename); 
 ~~~ 

 which would presumably need to become the Unicode `GetModuleFileNameW()` GetModuleFileNameW() 
 version instead? 


 Regards, 

 Bill 

Back