Repository navigation
Description
Download ruby 4.0.1 and build with msvc following the official instructions. Try to install a gem. Get an error like this:
gem install fiddle
ERROR: Loading command: install (NameError)
uninitialized constant Gem::Commands::InstallCommand
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:241:in 'Module#const_get'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:241:in 'Gem::CommandManager#load_and_instantiate'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:137:in 'Gem::CommandManager#[]'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:209:in 'Gem::CommandManager#find_command'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:250:in 'Gem::CommandManager#invoke_command'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:193:in 'Gem::CommandManager#process_args'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:151:in 'Gem::CommandManager#run'
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/gem_runner.rb:56:in 'Gem::GemRunner#run'
C:/msys64/usr/local/ruby/bin/gem.cmd:20:in '<main>'
Digging deeper, I removed the exception handling at line 236 in command_manager.rb - https://github.com/ruby/ruby/blob/ba8b0b3a9c867421166083c2eb35204c616beb4b/lib/rubygems/command_manager.rb#L236
Now I see:
gem install fiddle
error_highlight
did_you_mean
syntax_suggest
etc
fileutils
openssl
digest
io-nonblock
ipaddr
io-wait
win32-registry
win32-registry
C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1410:in 'block in Gem::Specification#activate_dependencies': Could not find 'fiddle' (~> 1.0) among 87 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=C:/Users/cfis/.local/share/gem/ruby/4.0.0;C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/gems/4.0.0' at: C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/gems/4.0.0/specifications/win32-registry-0.1.2.gemspec, execute `gem env` for more information
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1396:in 'Array#each'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1396:in 'Gem::Specification#activate_dependencies'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1378:in 'Gem::Specification#activate'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/core_ext/kernel_gem.rb:62:in 'block in Kernel#gem'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/core_ext/kernel_gem.rb:62:in 'Thread::Mutex#synchronize'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/core_ext/kernel_gem.rb:62:in 'Kernel#gem'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/resolv/lib/resolv.rb:1025:in 'Kernel#require'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/resolv/lib/resolv.rb:1025:in 'Gem::Resolv::DNS::Config.default_config_hash'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/resolv/lib/resolv.rb:94:in 'Gem::Resolv#initialize'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/resolv/lib/resolv.rb:3468:in '<class:Resolv>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/resolv/lib/resolv.rb:34:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/net-http/lib/net/http.rb:25:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendor/net-http/lib/net/http.rb:25:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendored_net_http.rb:5:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/vendored_net_http.rb:5:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/request.rb:3:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/request.rb:3:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/remote_fetcher.rb:4:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/remote_fetcher.rb:4:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/spec_fetcher.rb:3:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/spec_fetcher.rb:3:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/dependency_installer.rb:7:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/dependency_installer.rb:7:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/commands/install_command.rb:5:in 'Kernel#require_relative'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/commands/install_command.rb:5:in '<top (required)>'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:235:in 'Kernel#require'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:235:in 'Gem::CommandManager#load_and_instantiate'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:137:in 'Gem::CommandManager#[]'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:209:in 'Gem::CommandManager#find_command'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:250:in 'Gem::CommandManager#invoke_command'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:193:in 'Gem::CommandManager#process_args'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/command_manager.rb:151:in 'Gem::CommandManager#run'
from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/gem_runner.rb:56:in 'Gem::GemRunner#run'
from C:/msys64/usr/local/ruby/bin/gem.cmd:20:in '<main>'
The win32-registry gem requires fiddle which I'm trying to install. That causes an exception and the GEM commands are not loaded thus breaking ruby gems completely. You can't run any command, not even gem list. I have used msvc builds of Ruby for years and this has never happened before, so seems new for Ruby 4.0.
My hacky solution was to comment out activate_dependencies here:
That allowed me to install the ffi gem and thus fix rubygems.
But of course rubygems should not break just because a gem dependency cannot be loaded.
Activity
[-]MSWindows Build Broken[/-][+]MSWindows Builds Broken[/+]hsbt commentedon Jan 30, 2026
@cfis Thanks. It caused by
fiddleis not installed bynmake install. So, this is issue of ruby core, not rubygems.That being said, I think the inability to install gems when
win32-registrycannot be activated is a rubygems issue.cfis commentedon Jan 30, 2026
Yes makes sense @hsbt. Is there anything else you would like me to do? Happy to test any fixes if you'd like.
Earlopain commentedon Jan 30, 2026
This should be solved by vendoring
resolv0.7.0 instead of 0.6.2. Also see https://bugs.ruby-lang.org/issues/21645For bundler/rubygems vendoring 0.7.0 should be fine I think, it will use
win32/resolvfrom the running ruby version which should work regardless of which ruby version the user has. Although, I did not test this since I don't have a windows machine.The issue of
win32-registrydepending onfiddlewill still be present though. I openend https://bugs.ruby-lang.org/issues/21855hsbt commentedon Feb 5, 2026
@cfis I update vendored resolv to 0.7.0 and released RubyGems 4.0.6 now. Can you try HEAD of ruby/ruby or update your rubygems with
gem update --system?cfis commentedon Feb 5, 2026
Thanks @hsbt - I will let you know.
cfis commentedon Feb 7, 2026
I deleted my Ruby 4.0.1 installation. Then reinstalled it (this is Visual Studio 2026 build):
Then I tried to update RubyGems. That fails (note I removed the exception handler at https://github.com/ruby/rubygems/blob/master/lib/rubygems/command_manager.rb#L236 to get this traceback):
So you can't get to a valid state with the Ruby 4.0.1 release.
Next, I do the same hack I did in the original post to uncomment
activate_dependencies.Then:
Then undo the hack, and try fiddle:
Great! It works! Thank you fixing this. I will try a mingw64 build and see if it also fails.
Hopefully a new Ruby release can be made soon with this fix.
cfis commentedon Feb 7, 2026
mingw64 is fine:
hsbt commentedon Feb 18, 2026
Thanks. It's my wrong request. I should suggest to use
ruby setup.rbinstead ofgem update --system.We backported RG 4.0.6 to
ruby_4_0branch at ruby/ruby#16124. It should fix this report at Ruby 4.0.2.cfis commentedon Feb 18, 2026
Great. Thanks for the help! I will close this as done.