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

allow missing devkit #277

Merged
merged 1 commit into from
Sep 28, 2021
Merged

Conversation

jmartin-tech
Copy link
Contributor

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

  • Bug fix.

Testing

  • I tested my changes locally.

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.
@jmartin-tech
Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor Author

Can this be merged?

@ioquatix ioquatix merged commit f68b399 into socketry:master Sep 28, 2021
@jmartin-tech jmartin-tech deleted the allow-missing-devkit branch September 28, 2021 20:08
@jmartin-tech
Copy link
Contributor Author

@ioquatix thanks for landing!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants