安装rails时出错无法构建gem原生扩展

时间:2018-03-18 15:39:59

标签: ruby-on-rails ruby

所以我尝试使用本指南安装Rails: http://guides.rubyonrails.org/getting_started.html

我一直收到这个错误(见下文)。

有什么建议吗?

我正在使用cmd(Windows 8)。

(c)2013 Microsoft Corporation。保留所有权利。

我打字:ruby -v

然后我得到:ruby 2.4.3p205 (2017-12-14 revision 61247) [x64-mingw32]

我打字:sqlite3 --version

然后我得到:3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e 86726f2171d

我打字:gem install rails

然后我得到:

Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/websocket-driver-0
.6.5/ext/websocket-driver
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20180318-5748-xd7wo5.rb extconf.rb
creating Makefile

current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/websocket-driver-0.6.5
/ext/websocket-driver
make "DESTDIR=" clean

current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/websocket-driver-0.6.5
/ext/websocket-driver
make "DESTDIR="
generating websocket_mask-x64-mingw32.def
make: *** No rule to make target `/C/Ruby24-x64/include/ruby-2.4.0/ruby.h', need
ed by `websocket_mask.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/websoc
ket-driver-0.6.5 for inspection.
Results logged to C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0
/websocket-driver-0.6.5/gem_make.out

2 个答案:

答案 0 :(得分:1)

我使用websocket-driver本机扩展(Windows 10)遇到了完全相同的问题,错误消息完全相同:

make: *** No rule to make target `/C/Ruby24-x64/include/ruby-2.4.0/ruby.h', need
ed by `websocket_mask.o'.  Stop.

make failed, exit code 2

我的解决方案是在“ MSYS2-Devkit”安装过程中注意选择选项“ 3” (MSYS2和MINGW开发工具链)

在我的案例中,“捆绑安装”安装并编译了Rails项目的所有依赖项

答案 1 :(得分:0)

尝试使用Cygwin使用rvm。它应该有助于解决ruby版本问题。

请参阅https://rvm.io/rvm/install