安装旧版本 Rails 5.2.2 时出现问题 - 无法构建 gem 本机扩展

发布于 2025-01-09 14:22:16 字数 3246 浏览 0 评论 0原文

我需要在Windows 10上安装旧版本的rails - 5.2.2。我是bash新手,所以我盲目地进入了这个任务,但我设法安装了Ruby 2.5.0p0(我也需要)。现在我已经被困了几个小时试图弄清楚如何安装导轨。 运行后: $ gem install Rails -v 5.2.2 我遇到以下错误消息:

        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby25/lib/ruby/gems/2.5.0/gems/racc-1.6.0/ext/racc/cparse
C:/Ruby25/bin/ruby.exe -r ./siteconf20220223-16448-scx6bw.rb extconf.rb
checking for rb_block_call()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby25/bin/$(RUBY_BASE_NAME)
C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:770:in `try_func'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:1057:in `block in have_func'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:320:in `open'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:320:in `open'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:1056:in `have_func'
        from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x86-mingw32/2.5.0/racc-1.6.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby25/lib/ruby/gems/2.5.0/gems/racc-1.6.0 for inspection.
Results logged to C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x86-mingw32/2.5.0/racc-1.6.0/gem_make.out
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...

mkmf 日志:

"i686-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25/include/ruby-2.5.0/i386-mingw32 -IC:/Ruby25/include/ruby-2.5.0/ruby/backward -IC:/Ruby25/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=i686 -mtune=generic -O2 -pipe conftest.c  -L. -LC:/Ruby25/lib -L. -pipe     -lmsvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

我正在使用 git bash 以防万一。

I need to install older version of rails - 5.2.2 on Windows 10. I'm new to bash, so I went into this task blind, but I managed to install Ruby 2.5.0p0(which I also need). Now I've been stuck for few hours trying to figure out how to install rails.
After running:
$ gem install rails -v 5.2.2
I'm met with following error message:

        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby25/lib/ruby/gems/2.5.0/gems/racc-1.6.0/ext/racc/cparse
C:/Ruby25/bin/ruby.exe -r ./siteconf20220223-16448-scx6bw.rb extconf.rb
checking for rb_block_call()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby25/bin/$(RUBY_BASE_NAME)
C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:541:in `try_link0'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:770:in `try_func'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:1057:in `block in have_func'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:947:in `block in checking_for'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:320:in `open'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:320:in `open'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:946:in `checking_for'
        from C:/Ruby25/lib/ruby/2.5.0/mkmf.rb:1056:in `have_func'
        from extconf.rb:6:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x86-mingw32/2.5.0/racc-1.6.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby25/lib/ruby/gems/2.5.0/gems/racc-1.6.0 for inspection.
Results logged to C:/Ruby25/lib/ruby/gems/2.5.0/extensions/x86-mingw32/2.5.0/racc-1.6.0/gem_make.out
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...

The mkmf log:

"i686-w64-mingw32-gcc -o conftest.exe -IC:/Ruby25/include/ruby-2.5.0/i386-mingw32 -IC:/Ruby25/include/ruby-2.5.0/ruby/backward -IC:/Ruby25/include/ruby-2.5.0 -I. -D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64  -march=i686 -mtune=generic -O2 -pipe conftest.c  -L. -LC:/Ruby25/lib -L. -pipe     -lmsvcrt-ruby250  -lgmp -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi  "
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

I'm using git bash in case that matters.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难如初 2025-01-16 14:22:16

使用 sudo apt install ruby​​ 安装 ruby​​ 时出现此问题。

解决方案:通过RVM安装ruby。

The problem occurred when ruby was installed using sudo apt install ruby.

Solution: Install ruby via RVM.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文