无法在Cygwin上使用RVM安装Ruby

时间:2015-06-03 18:38:56

标签: ruby-on-rails ruby cygwin rvm git-bash

我在Windows上,目前我使用的是Ruby v2.1.5,因为RailsInstaller附带了它。但是,对于另一个项目,我需要降级到2.1.1,我不确定如何。

我已经在Cygwin上安装了rvm,并且在尝试执行rvm install 2.1.1

时遇到了这些问题
Searching for binary rubies, this might take some time.
No binary rubies available for: cygwin/unknown/x86_64/ruby-2.1.1.
Continuing with compilation. Please read 'rvm help mount' to get more 
information on binary rubies.

Checking requirements for cygwin.
Installing requirements for cygwin.
Updating system.
Installing required packages: mingw64-i686-gcc, mingw64-x86_64-gcc.
Requirements installation successful.
Installing Ruby from source to: /home/K/.rvm/rubies/ruby-2.1.1, this may take a while depending on your cpu(s)...
ruby-2.1.1 - #downloading ruby-2.1.1, this may take a while depending on your connection...
ruby-2.1.1 - #extracting ruby-2.1.1 to /home/K/.rvm/src/ruby-2.1.1....
ruby-2.1.1 - #applying patch /home/K/.rvm/patches/ruby/2.1.1/libyaml.patch.
ruby-2.1.1 - #applying patch /home/K/.rvm/patches/ruby/changeset_r45225.diff.
ruby-2.1.1 - #applying patch /home/K/.rvm/patches/ruby/changeset_r45240.diff.
ruby-2.1.1 - #configuring....................................................
ruby-2.1.1 - #post-configuration..
ruby-2.1.1 - #compiling....................................................
Error running '__rvm_make -j4',
showing last 15 lines of /home/K/.rvm/log/1433355357_ruby-2.1.1/make.log
make[2]: Leaving directory '/home/K/.rvm/src/ruby-2.1.1/ext/-test-/printf'
exts.mk:109: recipe for target 'ext/-test-/printf/all' failed
make[1]: *** [ext/-test-/printf/all] Error 2
make[1]: *** Waiting for unfinished jobs....
installing default rational libraries
installing default recursion libraries
make[2]: Leaving directory '/home/K/.rvm/src/ruby-2.1.1/ext/-test-/postponed_job'
linking shared-object -test-/rational.so
linking shared-object -test-/recursion.so
make[2]: Leaving directory '/home/K/.rvm/src/ruby-2.1.1/ext/-test-/recursion'
make[2]: Leaving directory '/home/K/.rvm/src/ruby-2.1.1/ext/-test-/rational'
make[1]: Leaving directory '/home/K/.rvm/src/ruby-2.1.1'
uncommon.mk:180: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2
++ return 2
There has been an error while running make. Halting the installation.

任何帮助将不胜感激。感谢

1 个答案:

答案 0 :(得分:0)

你需要修补ruby soure代码,以便在cygwin上编译。值得庆幸的是,rvm支持开箱即用的补丁!

使用以下内容创建名为cygwin.patch的文件:

--- /ext/-test-/printf/printf.c 2014-06-29 10:17:20.000000000 -0700
+++ /ext/-test-/printf/printf.c 2015-07-08 16:58:15.882479100 -0700
@@ -1,3 +1,4 @@
+#define __STRICT_ANSI__ /* avoid conflicting utoa */
#include <ruby.h>
#include <ruby/encoding.h>

现在只需使用rvm参数执行--patch,如下所示:

rvm install 2.2-head --patch cygwin.patch