ridk install fails on Ruby <= 3.0.x when there is a special character in path
What problems are you experiencing?
When running ridk with Ruby <= 3.0.x from a path, including special characters (e.g. Umlauts), the ridk script crashes instantly.
Steps to reproduce
Install any ruby version <= 3.0.x from Rubyinstaller inside a path with special character, ensure PATH variable to its bin directory is set or open the bin directory in the command line. In my case they were installed in the user directory with a username containing a special character.
Running latest Windows 11, German locale.
Then run:
ridk install 1 2 3
The output will be:
Traceback (most recent call last):
9: from <internal:gem_prelude>:1:in `<internal:gem_prelude>'
8: from <internal:gem_prelude>:1:in `require'
7: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/2.7.0/rubygems.rb:1427:in `<top (required)>'
6: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/2.7.0/rubygems.rb:1427:in `require'
5: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/2.7.0/rubygems/defaults/operating_system.rb:24:in `<top (required)>'
4: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/singleton.rb:27:in `enable_dll_search_paths'
3: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:126:in `enable_dll_search_paths'
2: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:126:in `new'
1: from C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/dll_directory.rb:64:in `initialize'
C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/dll_directory.rb:104:in `add_dll_directory_winapi': AddDllDirectory failed for C:/Users/Matthäus/.rvm/envs/ruby-2.7.8/msys64/mingw64/bin (RubyInstaller::Runtime::DllDirectory::WinApiError)
What's the output from ridk version?
Does not run as well, the output in this case is excactly the same as mentioned above. No ridk command is working at all. I tried the latest Ruby 2.7.8 and 3.0.7 from RubyInstaller without any modification.
Additional info
From Ruby >= 3.1.x it works without any problems, if there is a special character in the path of the ruby installation.
On Ruby 2.4.10 / 2.5.9 / 2.6.10 the error is different, here the path itself is encoded the wrong way when running ridk:
<internal:gem_prelude>:4:in `require': No such file or directory -- C:/Users/Matthäus/.rvm/envs/ruby-2.4.10/lib/ruby/2.4.0/rubygems.rb (LoadError)
from <internal:gem_prelude>:4:in `<internal:gem_prelude>'
Messy issue.
All the affected Rubies are EOL. Also, they report ASCII-8BIT to the following, but Ruby 3.0 and later report UTF-8:
ruby -e "puts ENV['PATH'].encoding"
See https://github.com/ruby/ruby/pull/3818
ridk could be patched to work around these issues, but that still leaves issues with Ruby itself...
@MSP-Greg thank you very much for your response!
I noticed this problem because I am currently developing a version manager for the classic Windows Command Line that is compatible with RVM.io.
Since special characters in the path are probably a special Edge case as long as you do not install in the user directory, I will check to generally switch to C:\ProgramData by default, making it even more easier to reuse it for multi user environments.
So i guess, it is not worth to make a patch for this, but to mention this problem in the docs benath the problem with empty spaces in paths, to avoid using paths with special characters: PullRequest: https://github.com/oneclick/rubyinstaller2/pull/381
There will be no further ruby-3.0.x release since it is EOL. And with #381 merged I think we can close this issue.