Skip to content

MSWindows Builds Broken #9277

Closed
Closed

Description

@cfis

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:

https://github.com/ruby/ruby/blob/ba8b0b3a9c867421166083c2eb35204c616beb4b/lib/rubygems/specification.rb#L1384.

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

  1. changed the title [-]MSWindows Build Broken[/-] [+]MSWindows Builds Broken[/+] on Jan 29, 2026
  2. hsbt commented on Jan 30, 2026

    @hsbt
    Member

    @cfis Thanks. It caused by fiddle is not installed by nmake install. So, this is issue of ruby core, not rubygems.

    That being said, I think the inability to install gems when win32-registry cannot be activated is a rubygems issue.

  3. cfis commented on Jan 30, 2026

    @cfis
    ContributorAuthor

    Yes makes sense @hsbt. Is there anything else you would like me to do? Happy to test any fixes if you'd like.

  4. Earlopain commented on Jan 30, 2026

    @Earlopain
    Contributor

    This should be solved by vendoring resolv 0.7.0 instead of 0.6.2. Also see https://bugs.ruby-lang.org/issues/21645

    For bundler/rubygems vendoring 0.7.0 should be fine I think, it will use win32/resolv from 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-registry depending on fiddle will still be present though. I openend https://bugs.ruby-lang.org/issues/21855

  5. hsbt commented on Feb 5, 2026

    @hsbt
    Member

    @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?

  6. cfis commented on Feb 5, 2026

    @cfis
    ContributorAuthor

    Thanks @hsbt - I will let you know.

  7. cfis commented on Feb 7, 2026

    @cfis
    ContributorAuthor

    I deleted my Ruby 4.0.1 installation. Then reinstalled it (this is Visual Studio 2026 build):

    nmake install
    

    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):

    >gem update --system
    C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1408:in 'block in Gem::Specification#activate_dependencies': Could not find 'fiddle' (~> 1.0) among 84 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:1394:in 'Array#each'
            from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1394:in 'Gem::Specification#activate_dependencies'
            from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/specification.rb:1376: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/update_command.rb:5:in 'Kernel#require_relative'
            from C:/msys64/usr/local/ruby-4.0.1-mswin/lib/ruby/4.0.0/rubygems/commands/update_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:249: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>'
    

    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:

    >gem update --system
    Fetching rubygems-update-4.0.6.gem
    Successfully installed rubygems-update-4.0.6
    Parsing documentation for rubygems-update-4.0.6
    Installing ri documentation for rubygems-update-4.0.6
    Done installing documentation for rubygems-update after 0 seconds
    Parsing documentation for rubygems-update-4.0.6
    Done installing documentation for rubygems-update after 0 seconds
    Installing RubyGems 4.0.6
    etc...
    

    Then undo the hack, and try fiddle:

    >gem install fiddle
    Fetching fiddle-1.1.8.gem
    Building native extensions. This could take a while...
    Successfully installed fiddle-1.1.8
    Parsing documentation for fiddle-1.1.8
    Installing ri documentation for fiddle-1.1.8
    Done installing documentation for fiddle after 1 seconds
    1 gem installed
    

    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.

  8. cfis commented on Feb 7, 2026

    @cfis
    ContributorAuthor

    mingw64 is fine:

    UCRT64 /c/Source
    $ gem update --system
    Fetching rubygems-update-4.0.6.gem
    Successfully installed rubygems-update-4.0.6
    Parsing documentation for rubygems-update-4.0.6
    Installing ri documentation for rubygems-update-4.0.6
    Done installing documentation for rubygems-update after 0 seconds
    Parsing documentation for rubygems-update-4.0.6
    Done installing documentation for rubygems-update after 0 seconds
    Installing RubyGems 4.0.6
      Successfully built RubyGem
      Name: bundler
      Version: 4.0.6
      File: bundler-4.0.6.gem
    
  9. hsbt commented on Feb 18, 2026

    @hsbt
    Member

    Thanks. It's my wrong request. I should suggest to use ruby setup.rb instead of gem update --system.

    We backported RG 4.0.6 to ruby_4_0 branch at ruby/ruby#16124. It should fix this report at Ruby 4.0.2.

  10. cfis commented on Feb 18, 2026

    @cfis
    ContributorAuthor

    Great. Thanks for the help! I will close this as done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions