https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17113305112019-07-12T10:15:06ZRuby Issue Tracking SystemRuby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=793512019-07-12T10:15:06Zinversion (Yura Babak)
<ul></ul><p>Looks like there is an <strong>ugly workaround</strong>.</p>
<ol>
<li>Ensure to do <code>chcp 1251</code> in the current console session.</li>
<li>Run Ruby with an option <code>--disable=gems</code> so it will not fail initially.</li>
<li>Add next code at the very beginning of a script:</li>
</ol>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="k">if</span> <span class="vg">$:</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">encoding</span><span class="p">.</span><span class="nf">name</span> <span class="o">==</span> <span class="s1">'Windows-1251'</span>
<span class="vg">$:</span><span class="p">.</span><span class="nf">each</span> <span class="p">{</span><span class="o">|</span><span class="n">path</span><span class="o">|</span> <span class="n">path</span><span class="p">.</span><span class="nf">encode!</span> <span class="s1">'UTF-8'</span> <span class="p">}</span>
<span class="vg">$:</span><span class="p">.</span><span class="nf">push</span> <span class="s1">'.'</span> <span class="c1"># somehow it helps, looks like a modification of array is needed</span>
<span class="nb">require</span> <span class="s1">'rubygems'</span>
<span class="k">end</span>
</code></pre>
<p>This helped me to overcome the problem and run my script from a folder with Cyrillic and spaces in the path.</p>
<p>But it definitely should be fixed.</p> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=802962019-07-31T04:21:04Zduerst (Martin Dürst)duerst@it.aoyama.ac.jp
<ul></ul><p><a class="user active user-mention" href="https://bugs.ruby-lang.org/users/17">@ko1 (Koichi Sasada)</a>: I can check whether this bug is reproducible. But I'm not too familiar with how Ruby deals with the Windows file system. So I'm not confident I will be able to find and fix this bug.</p> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=803312019-08-01T14:06:31ZMSP-Greg (Greg L)
<ul></ul><p>On a US Windows system, I used a base Ruby folder of <code>C:\Greg\Ruby киї</code> (using a space and Cyrillic characters), and I could repo the issue.</p>
<p>Without any console chcp command, I did the following, which also solved the issue:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># start ruby with --disable=gems</span>
<span class="vg">$:</span><span class="p">.</span><span class="nf">map!</span> <span class="p">{</span> <span class="o">|</span><span class="n">path</span><span class="o">|</span> <span class="n">path</span><span class="p">.</span><span class="nf">dup</span><span class="p">.</span><span class="nf">force_encoding</span> <span class="s1">'UTF-8'</span> <span class="p">}</span>
<span class="nb">require</span> <span class="s1">'rubygems'</span>
<span class="nb">require</span> <span class="s1">'openssl'</span>
<span class="nb">puts</span> <span class="no">OpenSSL</span><span class="o">::</span><span class="no">VERSION</span>
</code></pre>
<p>I don't think spaces in Windows paths is an issue anymore, but I haven't rigorously checked...</p> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=803342019-08-01T20:25:28ZMSP-Greg (Greg L)
<ul></ul><p>While taking a break, looked at this again. Below is the encoding of various items:</p>
<pre><code>$LOAD_PATH
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/site_ruby/2.7.0
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/site_ruby/2.7.0/x64-msvcrt
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/site_ruby
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/vendor_ruby/2.7.0
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/vendor_ruby/2.7.0/x64-msvcrt
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/vendor_ruby
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/2.7.0
ASCII-8BIT C:/Greg/Ruby киї/lib/ruby/2.7.0/x64-mingw32
IBM437 __FILE__
IBM437 __dir__
UTF-8 Dir.pwd
</code></pre>
<p>The encoding wasn't affected by using <code>-E</code> in <code>RUBYOPT</code>.</p>
<p>Tested using today's trunk.</p> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=872712020-08-28T22:47:56Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Related to</strong> <i><a class="issue tracker-1 status-5 priority-4 priority-default closed" href="/issues/15655">Bug #15655</a>: Unable to handle Russian dirname on Windows</i> added</li></ul> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=878042020-09-29T14:04:08Ztschoening (Thorsten Schöning)
<ul></ul><p>I think I have a similar problem originally reported at GitHub already:</p>
<p><a href="https://github.com/rubygems/rubygems/issues/3853" class="external">https://github.com/rubygems/rubygems/issues/3853</a></p>
<p>I have a Ruby-based shell application which needs to require a library during startup. I'm using the following command line:</p>
<pre><code class="shell syntaxhl" data-language="shell"><span class="s2">"..</span><span class="se">\r</span><span class="s2">uby</span><span class="se">\b</span><span class="s2">in</span><span class="se">\r</span><span class="s2">uby.exe"</span> <span class="s2">"-I../runtime/lib"</span> <span class="s2">"../visualizer/bin/ksv"</span> <span class="s2">"--require=de/[...]/par_opp_dispatcher.rb"</span> <span class="s2">"--opaque-types=true"</span> <span class="s2">"../files_to_show/recs_clt.bin"</span> <span class="s2">"de/[...]/par_recs_clt.rb"</span>
</code></pre>
<p>This results in the following error, while the first line describes the current directory I'm in. It contains some German umlaut <code>ü</code>. Using an ASCII-only path, things work as expected.</p>
<pre><code class="shell syntaxhl" data-language="shell">C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\k</span>s_ruby_visualizer>show.cmd
Traceback <span class="o">(</span>most recent call last<span class="o">)</span>:
1: from <internal:gem_prelude>:2:in <span class="sb">`</span><internal:gem_prelude><span class="s1">'
<internal:gem_prelude>:2:in `require'</span>: No such file or directory <span class="nt">--</span> C:/[...]/Müller electronic/[...]/rubygems.rb <span class="o">(</span>LoadError<span class="o">)</span>
</code></pre>
<p>The problem seems to be that at some point Ruby really seems to forward UTF-8 encoded bytes into the file system and such a path simply doesn't exist. The interesting thing is that many times before the path is forwarded correctly according to the following ProcMon-log:</p>
<pre><code class="shell syntaxhl" data-language="shell">18:57:48,7938985 ruby.exe 15296 CreateFile C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\r</span>ubygems.rb SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
18:57:48,7940217 ruby.exe 15296 QueryBasicInformationFile C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\r</span>ubygems.rb SUCCESS CreationTime: 24.07.2020 14:48:44, LastAccessTime: 24.07.2020 14:48:44, LastWriteTime: 01.10.2019 23:01:05, ChangeTime: 04.02.2020 22:30:28, FileAttributes: A 0x80000
18:57:48,7940500 ruby.exe 15296 CloseFile C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\r</span>ubygems.rb SUCCESS
18:57:48,7942644 ruby.exe 15296 CreateFile C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\r</span>ubygems.rb SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
18:57:48,7943188 ruby.exe 15296 CloseFile C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\r</span>ubygems.rb SUCCESS
18:57:48,7945545 ruby.exe 15296 CreateFile C:<span class="se">\[</span>...]<span class="se">\M</span>üller electronic<span class="se">\[</span>...]<span class="se">\r</span>ubygems.rb PATH NOT FOUND Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a
</code></pre>
<p><img src="https://user-images.githubusercontent.com/6223655/88416199-13655d80-cde0-11ea-9b0d-2319b6c3af2b.png" alt="Clipboard01"></p>
<p>Here are my current environment details:</p>
<pre><code class="shell syntaxhl" data-language="shell"><span class="nv">$ </span>gem <span class="nb">env </span>version
3.0.3
</code></pre>
<ul>
<li>Windows 10 1909 x86-64</li>
<li>default codepages Windows-1252 and CP-850</li>
<li>Ruby 2.6.5</li>
</ul> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=925402021-06-16T17:53:55Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li></ul><p>This appears to be fixed starting in Ruby 2.7 (also works in 3.0):</p>
<pre><code>D:\Евгений>C:\Ruby26-x64\bin\ruby -I D:\Евгений -e "require 'logger'"
Traceback (most recent call last):
2: from -e:1:in `<main>'
1: from C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
C:/Ruby26-x64/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': No such file or directory -- D:/Евгений/logger.rb (LoadError)
D:\Евгений>C:\Ruby27-x64\bin\ruby -I D:\Евгений -e "require 'logger'"
D:\Евгений>C:\Ruby30-x64\bin\ruby -I D:\Евгений -e "require 'logger'"
</code></pre>
<p>As Ruby 2.6 is in security maintenance mode, the change will not be backported.</p> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=928462021-07-09T11:12:22Zinversion (Yura Babak)
<ul></ul><p>jeremyevans0 (Jeremy Evans) wrote in <a href="#note-7">#note-7</a>:</p>
<blockquote>
<p>This appears to be fixed starting in Ruby 2.7 (also works in 3.0):</p>
</blockquote>
<p><strong>Still, there is a problem.</strong><br>
<code>require 'bundler/setup'</code> fails if <code>LOAD_PATH</code> or <code>Gem.dir</code> contain Cyrillic chars, the error is similar to:</p>
<pre><code>incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
</code></pre>
<p>From the trace I have prepared the <strong>minimum reproducible case</strong> :</p>
<ol>
<li>Put Ruby in a location where the path will contain Cyrillic chars, like <code>"D:\users\киї\Ruby"</code>
</li>
<li>Prepare 2 files (saved in UTF-8 encoding) somewhere in a location where the path will contain Cyrillic chars (can be near that Ruby):<br>
<a href="https://gist.github.com/Inversion-des/75949795cc5be707c19d31901e79d1cf" class="external">https://gist.github.com/Inversion-des/75949795cc5be707c19d31901e79d1cf</a>
</li>
<li>Open cmd and ensure to do <code>chcp 1251</code> in the current console session.</li>
<li>run <code>"[this Ruby path]" f1.rb</code>
</li>
</ol>
<p>You will see that the same <code>__dir__</code> output is different between files (f2 is required). If you will try to run f2.rb — output will be the same as for f1. So, <strong>require_relative somehow changes the encoding</strong> here.</p>
<p>To emulate problems with the 'bundler/setup' there are next lines:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="c1"># fails: incompatible character encodings: Windows-1251 and UTF-8 (Encoding::CompatibilityError)</span>
<span class="nb">p</span> <span class="n">start_with</span><span class="p">:</span><span class="vg">$LOAD_PATH</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">start_with?</span><span class="p">(</span><span class="n">__dir__</span><span class="p">)</span>
<span class="c1"># fails: incompatible character encodings: UTF-8 and ASCII-8BIT (Encoding::CompatibilityError)</span>
<span class="nb">p</span> <span class="n">start_with</span><span class="p">:</span><span class="vg">$LOAD_PATH</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">start_with?</span><span class="p">(</span><span class="no">Gem</span><span class="p">.</span><span class="nf">dir</span><span class="p">)</span>
</code></pre>
<p>To see the real problem you should comment these lines and also prepare next files (I'm not sure content is important by add at least one gem there)</p>
<ul>
<li>Gemfile</li>
<li>Gemfile.lock</li>
</ul>
<p>And to see both problems there should also be the <code>.bundle\config</code> file with a line like:<br>
<code>BUNDLE_PATH: "../platform/Ruby_gems"</code></p>
<p>In the <code>bundler\settings.rb</code> it will use <code>explicit_path</code> if the <code>BUNDLE_PATH</code> defined and <code>Bundler.rubygems.gem_dir</code> otherwise.</p>
<p>Workaround to overcome both errors you can find in the f1.rb in the related commented section:</p>
<pre><code class="ruby syntaxhl" data-language="ruby"><span class="no">Gem</span><span class="p">.</span><span class="nf">dir</span><span class="p">.</span><span class="nf">force_encoding</span> <span class="s1">'UTF-8'</span>
<span class="no">Gem</span><span class="p">.</span><span class="nf">path</span><span class="p">.</span><span class="nf">each</span> <span class="p">{</span><span class="o">|</span><span class="n">path</span><span class="o">|</span> <span class="n">path</span><span class="p">.</span><span class="nf">force_encoding</span> <span class="s1">'UTF-8'</span> <span class="p">}</span>
<span class="k">if</span> <span class="vg">$:</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nf">encoding</span><span class="p">.</span><span class="nf">name</span> <span class="o">==</span> <span class="s1">'Windows-1251'</span>
<span class="vg">$:</span><span class="p">.</span><span class="nf">each</span> <span class="p">{</span><span class="o">|</span><span class="n">path</span><span class="o">|</span> <span class="n">path</span><span class="p">.</span><span class="nf">encode!</span> <span class="s1">'UTF-8'</span> <span class="p">}</span>
<span class="vg">$:</span><span class="p">.</span><span class="nf">push</span> <span class="s1">'.'</span> <span class="c1"># somehow it helps, looks like a modification of array is needed</span>
<span class="k">end</span>
</code></pre>
<p>My environment:</p>
<ul>
<li>Windows10 Pro</li>
<li>Ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]</li>
<li>Bundler version 2.2.22</li>
<li>RubyGems version 3.2.22</li>
</ul> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=928492021-07-09T15:51:59Zjeremyevans0 (Jeremy Evans)merch-redmine@jeremyevans.net
<ul><li><strong>Status</strong> changed from <i>Closed</i> to <i>Open</i></li></ul><p>inversion (Yura Babak) wrote in <a href="#note-8">#note-8</a>:</p>
<blockquote>
<p>jeremyevans0 (Jeremy Evans) wrote in <a href="#note-7">#note-7</a>:</p>
<blockquote>
<p>This appears to be fixed starting in Ruby 2.7 (also works in 3.0):</p>
</blockquote>
<p><strong>Still, there is a problem.</strong><br>
<code>require 'bundler/setup'</code> fails if <code>LOAD_PATH</code> or <code>Gem.dir</code> contain Cyrillic chars, the error is similar to:</p>
<pre><code>incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
</code></pre>
<p>From the trace I have prepared the <strong>minimum reproducible case</strong> :</p>
<ol>
<li>Put Ruby in a location where the path will contain Cyrillic chars, like <code>"D:\users\киї\Ruby"</code>
</li>
<li>Prepare 2 files (saved in UTF-8 encoding) somewhere in a location where the path will contain Cyrillic chars (can be near that Ruby):<br>
<a href="https://gist.github.com/Inversion-des/75949795cc5be707c19d31901e79d1cf" class="external">https://gist.github.com/Inversion-des/75949795cc5be707c19d31901e79d1cf</a>
</li>
<li>Open cmd and ensure to do <code>chcp 1251</code> in the current console session.</li>
<li>run <code>"[this Ruby path]" f1.rb</code>
</li>
</ol>
</blockquote>
<p>I was able to reproduce the issue, but only when I installed Ruby into a path not supported by the <code>Windows-1251</code> encoding:</p>
<pre><code>d:\Евгений>d:\zz-können2\Ruby31-x64\bin\bundle install --local
d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:94:in `expand_path': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:94:in `expand_path'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:94:in `bundle_path'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:682:in `configure_gem_home'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:663:in `configure_gem_home_and_path'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:80:in `configure'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler.rb:193:in `definition'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/cli/install.rb:57:in `run'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/cli.rb:259:in `block in install'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/settings.rb:133:in `temporary'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/cli.rb:258:in `install'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/cli.rb:30:in `dispatch'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/cli.rb:24:in `start'
from d:/zz-können2/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.0.dev/libexec/bundle:49:in `block in <top (required)>'
from d:/zz-können2/Ruby31-x64/lib/ruby/3.1.0/bundler/friendly_errors.rb:130:in `with_friendly_errors'
from d:/zz-können2/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bundler-2.3.0.dev/libexec/bundle:37:in `<top (required)>'
from d:/zz-k?nnen2/Ruby31-x64/bin/bundle:31:in `load'
from d:/zz-k?nnen2/Ruby31-x64/bin/bundle:31:in `<main>'
</code></pre>
<p>Part of the underlying issue seems to be that <code>__FILE__</code> and <code>__dir__</code> are not UTF-8 encoded for the main script, unlike required files. I'm not sure if changing that alone will fix the issue, though.</p>
<p>When I run the following script (<code>f3.rb</code>):</p>
<pre><code>p ['__FILE__', __FILE__, __FILE__.encoding]
p ['__dir__', __dir__, __dir__.encoding]
p ['Gem.dir', Gem.dir, Gem.dir.encoding]
puts 'Gem.path'
Gem.path.each do |s|
p [s, s.encoding]
end
puts '$:'
$:.each do |s|
p [s, s.encoding]
end
</code></pre>
<p>I get the following when using Ruby installed in a non-ASCII path:</p>
<pre><code>d:\Евгений>d:\zz-können2\Ruby31-x64\bin\ruby D:\Евгений\f3.rb
["__FILE__", "D:/\xC5\xE2\xE3\xE5\xED\xE8\xE9/f3.rb", #<Encoding:Windows-1251>]
["__dir__", "D:/\xC5\xE2\xE3\xE5\xED\xE8\xE9", #<Encoding:Windows-1251>]
["Gem.dir", "d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/gems/3.1.0", #<Encoding:ASCII-8BIT>]
Gem.path
["C:/Users/jeremye/.gem/ruby/3.1.0", #<Encoding:UTF-8>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/gems/3.1.0", #<Encoding:ASCII-8BIT>]
$:
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/site_ruby/3.1.0", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/site_ruby/3.1.0/x64-ucrt", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/site_ruby", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/vendor_ruby/3.1.0", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/vendor_ruby/3.1.0/x64-ucrt", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/vendor_ruby", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/3.1.0", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/3.1.0/x64-mingw-ucrt", #<Encoding:ASCII-8BIT>]
</code></pre>
<p>and when installed into an ASCII path:</p>
<pre><code>d:\Евгений>C:\Ruby30-x64\bin\ruby d:\Евгений\f3.rb
["__FILE__", "d:/\xC5\xE2\xE3\xE5\xED\xE8\xE9/f3.rb", #<Encoding:Windows-1251>]
["__dir__", "d:/\xC5\xE2\xE3\xE5\xED\xE8\xE9", #<Encoding:Windows-1251>]
["Gem.dir", "C:/Ruby30-x64/lib/ruby/gems/3.0.0", #<Encoding:ASCII-8BIT>]
Gem.path
["C:/Users/jeremye/.gem/ruby/3.0.0", #<Encoding:UTF-8>]
["C:/Ruby30-x64/lib/ruby/gems/3.0.0", #<Encoding:ASCII-8BIT>]
$:
["C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/site_ruby/3.0.0/x64-msvcrt", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/site_ruby", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/vendor_ruby/3.0.0", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/vendor_ruby/3.0.0/x64-msvcrt", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/vendor_ruby", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/3.0.0", #<Encoding:Windows-1251>]
["C:/Ruby30-x64/lib/ruby/3.0.0/x64-mingw32", #<Encoding:Windows-1251>]
</code></pre>
<p>It looks like the difference in the non-ASCII path case is that <code>ASCII-8BIT</code> encoding is used even if the path itself is valid UTF-8. This is true even if you force a UTF-8 code page (though that does fix <code>__FILE__</code> and <code>__dir__</code>):</p>
<pre><code>d:\Евгений>chcp 65001
Active code page: 65001
d:\Евгений>d:\zz-können2\Ruby31-x64\bin\ruby D:\Евгений\f3.rb
["__FILE__", "D:/Евгений/f3.rb", #<Encoding:UTF-8>]
["__dir__", "D:/Евгений", #<Encoding:UTF-8>]
["Gem.dir", "d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/gems/3.1.0", #<Encoding:ASCII-8BIT>]
Gem.path
["C:/Users/jeremye/.gem/ruby/3.1.0", #<Encoding:UTF-8>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/gems/3.1.0", #<Encoding:ASCII-8BIT>]
$:
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/site_ruby/3.1.0", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/site_ruby/3.1.0/x64-ucrt", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/site_ruby", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/vendor_ruby/3.1.0", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/vendor_ruby/3.1.0/x64-ucrt", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/vendor_ruby", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/3.1.0", #<Encoding:ASCII-8BIT>]
["d:/zz-k\xC3\xB6nnen2/Ruby31-x64/lib/ruby/3.1.0/x64-mingw-ucrt", #<Encoding:ASCII-8BIT>]
</code></pre>
<p>Since there does appear to be an issue, I'll reopen this. Hopefully someone with more knowledge in this area can suggest a possible fix.</p> Ruby master - Bug #15993: 'require' doesn't work if there are Cyrillic chars in the path to Ruby dirhttps://bugs.ruby-lang.org/issues/15993?journal_id=928502021-07-09T16:08:40Zinversion (Yura Babak)
<ul><li><strong>ruby -v</strong> changed from <i>ruby 2.6.3p62 (2019-04-16 revision 67580) [x64-mingw32]</i> to <i>3.0.1p64 (2021-04-05 revision 0fb782ee38) [x64-mingw32]</i></li></ul>