socketry / nio4r

Cross-platform asynchronous I/O primitives for scalable network clients and servers.
Other
965 stars 86 forks source link

allow missing `devkit` #277

Closed jmartin-tech closed 2 years ago

jmartin-tech commented 2 years ago

Description

As per the comments in the build file, windows does not actually use any native extension code.

Not sure why the require was added for devkit. In the interest of compatibility simply guard the require with a rescue for the LoadError.

If the Ruby environment was custom built the devkit class will not always be available. In some cases such as more recent builds for Ruby 3.0.x the devkit can utilize an MSYS2 environment without needing the devkit class.

Types of Changes

Testing

jmartin-tech commented 2 years ago

Prior or this change gem installation results in failure to install:

gem.cmd install nio4r
Fetching nio4r-2.5.8.gem
Building native extensions. This could take a while...
ERROR:  Error installing nio4r:
        ERROR: Failed to build gem native extension.

    current directory: C:/ruby/lib/ruby/gems/3.0.0/gems/nio4r-2.5.8/ext/nio4r
C:/ruby/bin/ruby.exe -I C:/ruby/lib/ruby/site_ruby/3.0.0 -r ./siteconf20210818-5092-shxzq2.rb extconf.rb
<internal:C:/ruby/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- devkit (LoadError)
        from <internal:C:/ruby/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/ruby/lib/ruby/gems/3.0.0/gems/nio4r-2.5.8 for inspection.
Results logged to C:/ruby/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/nio4r-2.5.8/gem_make.out

With this revision:

gem.cmd install c:\test_gem\nio4r-2.5.8.gem
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.8
Parsing documentation for nio4r-2.5.8
Installing ri documentation for nio4r-2.5.8
Done installing documentation for nio4r after 0 seconds
1 gem installed
MSP-Greg commented 2 years ago

LGTM.

Not sure why the require was added for devkit.

It added MSYS2 paths to PATH.

more recent builds for Ruby 3.0.x the devkit can utilize an MSYS2 environment without needing the devkit class.

I think that is true for most RI2 installs (ruby 2.4 and later), as they add the MSYS2 paths via rubygems/defaults/operating_system.rb. But, when compiling code (as opposed to installing a gem), that may not be called. Hence, it was added to extconf.rb.

Regardless, this is needed for anyone using WIndows Ruby without the RubyInstaller2 RIDK files. They do need to make sure that compile/build tools are accessible in PATH.

jmartin-tech commented 2 years ago

Can this be merged?

jmartin-tech commented 2 years ago

@ioquatix thanks for landing!

Is there a schedule for getting a new release into rubygems.org based on this?