在 Windows 上的 JRuby 9.2.8.0 上安装 wdm gem

Installing wdm gem on JRuby 9.2.8.0 on Windows

我们正在将 Rails 项目从 2.3 转换为 5。

许多更改之一是启动消息:

Please add the following to your Gemfile to avoid polling for changes:
    gem 'wdm', '>= 0.1.0' if Gem.win_platform?

尝试在我的 JRuby 9.2.8.0 安装中安装 gem 时,我得到:

checking for main() in -lkernel32... RuntimeError: The compiler failed to
generate an executable file.
You have to install development tools first.
...
To see why this extension failed to compile, please check the mkmf.log which can
be found here:

M:/workspace/installations/jruby-9.2.8.0/lib/ruby/gems/shared/extensions/universal-java-1.8/2.5.0/wdm-0.1.1/mkmf.log

此文件包含:

" -o conftest.exe -I/include/universal-java1.8 -IM:/workspace/installations/jruby-9.2.8.0/lib/ruby/include/ruby/backward -IM:/workspace/installations/jruby-9.2.8.0/lib/ruby/include -I.     -fno-omit-frame-pointer -fno-strict-aliasing  -fexceptions  conftest.c  -L. -LM:/workspace/installations/jruby-9.2.8.0/lib  -LM:/workspace/installations/jruby-9.2.8.0/lib/native/x86_64-Windows   -m64 -march=native -mtune=native      "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <ruby.h>
4: int main(int argc, char **argv)
5: {
6:   return 0;
7: }
/* end */

注意:我可以在 ruby 2.6.4p104(2019-08-28 修订版 67798)[x64-mingw32] 上安装 gem,但不能安装在我的 JRuby 安装中

知道如何安装这个 gem 吗?

或者如果没有,我可以使用 wdm 的替代方法吗? 我注意到我的资产现在在开发中没有正确重新加载。

The first one is no longer relevant as JRuby does support C extensions nowadays.

这只是(不再)正确:C 扩展在 JRuby 1.6 周围得到了实验性支持,在 1.7 中,删除过程(它们从未真正工作得那么好)开始并且 9.X 不支持它们。如今,大多数原生 gem 都在 JRuby 上有一个 Java 特定的 ext 后端。

linked issue 试图在使用 JRuby 时建立一个 Java 特定版本,不幸的是它不是 finished/merged 但你可以尝试补丁。

您将需要使用禁用 C-ext 编译的补丁来设置一个 fork 存储库。或者您可以在 JRuby 上禁用 gem(并在您的应用程序中处理 'specific' 后端代码):

gem 'wdm', '>= 0.1.0', platform: [:mri, :mswin]