WinRb / WinRM

Ruby library for Windows Remote Management
Apache License 2.0
412 stars 117 forks source link

cannot load such file -- rexml/document (LoadError) #328

Closed noraj closed 2 years ago

noraj commented 3 years ago

evil-winrm requires winrm.

$ evil-winrm -h
bundler: failed to load command: evil-winrm.rb (evil-winrm.rb)
/usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/http/response_handler.rb:15:in `require': cannot load such file -- rexml/document (LoadError)
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/http/response_handler.rb:15:in `<top (required)>'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/http/transport.rb:16:in `require_relative'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/http/transport.rb:16:in `<top (required)>'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/http/transport_factory.rb:15:in `require_relative'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/http/transport_factory.rb:15:in `<top (required)>'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/connection.rb:16:in `require_relative'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm/connection.rb:16:in `<top (required)>'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm.rb:17:in `require_relative'
        from /usr/share/evil-winrm/vendor/bundle/ruby/3.0.0/gems/winrm-2.3.6/lib/winrm.rb:17:in `<top (required)>'
        from evil-winrm.rb:8:in `require'
        from evil-winrm.rb:8:in `<top (required)>'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:63:in `load'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:63:in `kernel_load'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/cli/exec.rb:28:in `run'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/cli.rb:494:in `exec'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/cli.rb:30:in `dispatch'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/cli.rb:24:in `start'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/exe/bundle:49:in `block in <top (required)>'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
        from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.2.17/exe/bundle:37:in `<top (required)>'
        from /usr/bin/bundle:23:in `load'
        from /usr/bin/bundle:23:in `<main>'

Is is due because rexml should be a runtime dependency and not a dev one?

https://github.com/WinRb/WinRM/blob/ebbed119340c665d8220298c0103f0f106b3bc6b/lib/winrm/http/response_handler.rb#L15

or because an incompatibility was brought by the last version of rexml because the version is not locked in the gemspec?

OscarAkaElvis commented 3 years ago

It seems doing gem install rexml fixes the problem. The reason is that before, rexml was a "default gem" and from ruby 3 or higher is a "bundled gem". Is explained here: https://stackoverflow.com/questions/65479863/rails-6-1-ruby-3-0-0-tests-error-as-they-cannot-load-rexml

Probably we should add it to evil-winrm Gemfile and Gemfile.lock.

OscarAkaElvis commented 3 years ago

We did a commit to fix this on future version: https://github.com/Hackplayers/evil-winrm/commit/83bc6ec050aaa97500ef6ff1ccd535d180ddb598

noraj commented 3 years ago

It seems doing gem install rexml fixes the problem. The reason is that before, rexml was a "default gem" and from ruby 3 or higher is a "bundled gem". Is explained here: https://stackoverflow.com/questions/65479863/rails-6-1-ruby-3-0-0-tests-error-as-they-cannot-load-rexml

Yes but since it's loaded at runtime it should be added as add_runtime_dependency rather than add_development_dependency in the gemspec.

OscarAkaElvis commented 3 years ago

Please, enable private messages on twitter or contact me on IRC or Discord (OscarAkaElvis#3764) to keep talking about this further.

noraj commented 3 years ago

I'll try to PM you on discord else https://docs.github.com/en/discussions

OscarAkaElvis commented 3 years ago

To add it as a runtime dependency is something that WinRM staff should do. From our side (evil-winrm team) already did a commit to fix it. Let's see what WinRM staff do.

postmodern commented 2 years ago

Also just ran into this. I think winrm should add rexml as a dependency since it's using it, Users and package managers will increasingly switch to Ruby 3.x and adding rexml as a dependency means you will get newer versions of the library.

fanbyprinciple commented 2 years ago

actually for me gem install winrm and gem install winrm-fs solved the issue

mwrock commented 2 years ago

oh yes fixed in #334