Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem install failure on Windows #2500

Closed
djberg96 opened this Issue Jan 22, 2015 · 22 comments

Comments

Projects
None yet
6 participants
@djberg96
Copy link
Contributor

djberg96 commented Jan 22, 2015

Windows 7
jruby 9.0.0.0.pre1 (2.2.0p0) 2015-01-20 d537cab Java HotSpot(TM) Client VM 24.51-b03 on 1.7.0_51-b13 +jit [Windows 7-x86]

C:\>jruby -S gem install test-unit
ERROR:  Loading command: install (Win32::Registry::Error)
The system cannot find the file specified.
ERROR:  While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass
@pandar1

This comment has been minimized.

Copy link

pandar1 commented Jan 26, 2015

same here on win server 2003

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 26, 2015

I've traced it to the 'load_and_instantiate' method in the command_manager.rb file. It looks right, but it's failing to load for some reason. Still digging.

@mistrya

This comment has been minimized.

Copy link

mistrya commented Jan 26, 2015

Hi
I ran into same issue when trying to install cucumber gem. Any luck @djberg96 ?

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 26, 2015

Not yet. I'm not even sure how win32-registry even enters into it.

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 26, 2015

Ok, it's trying to require rubygems/commands/install_command.rb. Which in turn makes several require calls. I tried calling them individually, until I found one that failed. Narrowed it down to rubygems/dependency_installer.rb:

irb(main):003:0> require 'rubygems/dependency_installer'
Win32::Registry::Error: The system cannot find the file specified.
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/registry.rb:319:in `QueryValue'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/registry.rb:642:in `read'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/registry.rb:702:in `read_s_expand'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/resolv.rb:129:in `get_hosts_dir'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/registry.rb:433:in `open'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/registry.rb:540:in `open'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/resolv.rb:128:in `get_hosts_dir'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/win32/resolv.rb:13:in `get_hosts_path'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/resolv.rb:174:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/remote_fetcher.rb:1:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/remote_fetcher.rb:6:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `__script__'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/spec_fetcher.rb:1:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `__script__'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/spec_fetcher.rb:1:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `__script__'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/dependency_installer.rb:1:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/dependency_installer.rb:5:in `require'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/dependency_installer.rb:5:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:1:in `(root)'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `eval'
    from C:/jruby-9.0.0.0.pre1/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:54:in `require'
    from (irb):3:in `evaluate'
    from C:/jruby-9.0.0.0.pre1/bin/jirb:13:in `__script__'irb(main):004:0> quit 
@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 26, 2015

Ok, more tracing, it happens if you "require 'resolv'". Now digging into that.

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 26, 2015

Here's the troublesome call:

require 'win32/resolv'
Win32::Resolv.get_hosts_path

MRI returns "C:/Windows/System32/drivers/etc/hosts". JRuby is choking.

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 26, 2015

Alright, narrowed that down even more. Here's the code bringing down the whole shebang.

require 'win32/registry'
include Win32

TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'

Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
  reg.read_s_expand('DataBasePath')
end
@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 27, 2015

Alright, I think it's as simple as this:

C:\jruby-9.0.0.0.pre1\lib\ruby\stdlib\win32>diff -u registry.bak registry.rb
--- registry.bak        Tue Jan 20 14:43:28 2015
+++ registry.rb Mon Jan 26 18:09:29 2015
@@ -280,7 +280,7 @@
       end

       def make_wstr(str)
-        str.encode(WCHAR)
+        str.encode(WCHAR) + 0.chr.encode(WCHAR)
       end

       def OpenKey(hkey, name, opt, desired)

After I made that change, it's working for me.

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 27, 2015

I should also add that I commented out all the win9x code logic from resolv.rb.

@headius

This comment has been minimized.

Copy link
Member

headius commented Jan 27, 2015

Hot damn, I love simple fixes. Wanna throw that and deleting the 9x logic (which I assume is gone from MRI as well) into a PR?

Anything else we can do to make our versions more similar to or exactly like MRI would be VERY welcome.

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 27, 2015

Just to clarify, the Windows 9x code I commented out was in resolv.rb. That's still in MRI.

@headius

This comment has been minimized.

Copy link
Member

headius commented Jan 27, 2015

Ahh, well the fix alone will be fine then :-) I doubt JRuby could run on 9x, but I hate maintaining stdlib diffs.

@michaelbuckner

This comment has been minimized.

Copy link

michaelbuckner commented Jan 29, 2015

I ran into a similar issue and made the same change as @djberg96 above. Unfortunately for me this did not resolve my issue.

gem install rails
ERROR: Loading command: install (LoadError)
load error: jopenssl/load -- java.lang.NullPointerException: null
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 29, 2015

@michaelbuckner I realized after reading your post that I've had my gem source set to "http://rubygems.org" for a long time. I think I got fed up with openssl errors. But, even after setting it back to "https://rubygems.org" I don't see an error.

Does it go away if you change your source to not use https? Not an ideal solution perhaps, but helps us nail down the issue.

@michaelbuckner

This comment has been minimized.

Copy link

michaelbuckner commented Jan 29, 2015

Nope, it does not.

gem install rails --source http://rubygems.org
ERROR: Loading command: install (LoadError)
load error: jopenssl/load -- java.lang.NullPointerException: null
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 29, 2015

Well, it was worth a shot. An NPE is a Java issue, though. Can you tell us more about your environment? Version of Windows, Java, etc.

@michaelbuckner

This comment has been minimized.

Copy link

michaelbuckner commented Jan 29, 2015

Windows 7 Ultimate 64bit
JRE Bundled with latest jruby installer (tried 1.8 too)

@djberg96

This comment has been minimized.

Copy link
Contributor Author

djberg96 commented Jan 29, 2015

@michaelbuckner I would file a separate issue.

@michaelbuckner

This comment has been minimized.

Copy link

michaelbuckner commented Jan 29, 2015

I did ; )

Thanks for your help.

@mistrya

This comment has been minimized.

Copy link

mistrya commented Jan 30, 2015

Apparently, it seems the issue was with the jRuby 9 pre installation
missing some files. I re-installed a new JRuby 9 pre and that resolved the
issue.

On Thu, Jan 29, 2015 at 8:22 AM, Michael Buckner notifications@github.com
wrote:

I ran into a similar issue and made the same change as @djberg96
https://github.com/djberg96 above. Unfortunately for me this did not
resolve my issue.

gem install rails
ERROR: Loading command: install (LoadError)
load error: jopenssl/load -- java.lang.NullPointerException: null
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass


Reply to this email directly or view it on GitHub
#2500 (comment).

@headius

This comment has been minimized.

Copy link
Member

headius commented Feb 23, 2015

Closing the loop on this...

The original issue was caused by win32/registry.rb not constructing wstrings properly. FFI will append a null character to strings, but only when declared as :string, which is currently always just a byte string. This should be improved, but in the short term since we're working with plain pointers we need to manually append the null bytes.

I believe this is resolved by #2523, and we have a separate issue for the NPE that @michaelbuckner reported.

@headius headius closed this Feb 23, 2015

@headius headius added this to the 9.0.0.0.pre2 milestone Feb 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.