From: Jon Forums Date: 2012-10-01T22:14:34+09:00 Subject: Re: Windows XP - Path encoding problem prevents script execution S. Hieko wrote in post #1078130: > Hello all, > > I've installed ruby 1.9.3 on a Windows XP box (french) for work related > purposes, with ruby installer from rubyinstaller.org. (same thing > happened on 1.9.2) > > Here is the content of a very simple script > #SCRIPT_START > puts "This should work, press a key to exit" > gets > #SCRIPT_END > > The script executes normally if saved to a path such as > "C:\Scripts\Ok\test.rb" > > However if saved to a path with an accent for instance > "C:\Scripts\Cliché\test.rb", I get an instant failure if I double click > on the script file. > > Going to the command line, if I type: > - C:\Scripts\Ok\test.rb => execution is ok. > - C:\Scripts\Cliché\test.rb => returns following error > "C:/Scripts/ClichÚ/test.rb: No such file or directory - > C:/Scripts/ClichÚ (Errno::ENOENT)" > - ruby C:\Scripts\Cliché\test.rb => execution is ok. > > This problem also causes failure if I need to use "require" pointing to > other scripts. For instance if I type inside irb: > > require "C:\\Scripts\\Ok\\test.rb" => execution is ok > require "C:\\Scripts\\Cliché\\test.rb" => failure to find file > > I have noticed there are many encodings being used all over the place. > > For instance in irb : > - Dir.pwd.encoding.name returns "Windows-1252" > - "test".encoding.name returns "CP850" > > So require "C:\\Scripts\\Cliché\\test.rb".encode("Windows-1252") seems > to solve that problem. > > regedit > HKEY_LOCAL_MACHINE\SOFTWARE\Classes\RubyFile\shell\open\command = > "C:\Ruby193\bin\ruby.exe" "%1" %* > > So I guess the ruby interpreter is expecting the script name as a string > in another encoding than that which is given by the windows subsystem. Looks like your cmd.exe defaults to codepage 850 and ruby doesn't like it. In an open Command Prompt set the active codepage to 1252 and run your command line tests again. chcp 1252 If the problem disappears, consider changing your default codepage by setting the OEMCP subkey of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage to 1252. Once you've rebooted, any Command Prompt you open will be in 1252 mode. Jon -- Posted via http://www.ruby-forum.com/.