无法在Cygwin上使用RVM安装Ruby

时间:2022-09-19 00:24:39

I'm on Windows and I currently have Ruby v2.1.5 as that is what came with RailsInstaller. However, I need to downgrade to 2.1.1 for another project and I'm not sure how to.

我在Windows上,我目前拥有Ruby v2.1.5,因为RailsInstaller附带了它。但是,我需要降级到另一个项目的2.1.1,我不知道如何。

I have installed rvm on Cygwin and I'm getting these problems when trying to execute rvm install 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.

and

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.

Any help would be appreciated. Thanks

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

1 个解决方案

#1


0  

You need to patch ruby soure code so it would compile on cygwin. Thankfully rvm supports patches out of the box!

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

Create a file called cygwin.patch with the following content:

使用以下内容创建名为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>

And now simply execute rvm with a --patch parameter like shown below:

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

rvm install 2.2-head --patch cygwin.patch

rvm install 2.2-head --patch cygwin.patch

#1


0  

You need to patch ruby soure code so it would compile on cygwin. Thankfully rvm supports patches out of the box!

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

Create a file called cygwin.patch with the following content:

使用以下内容创建名为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>

And now simply execute rvm with a --patch parameter like shown below:

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

rvm install 2.2-head --patch cygwin.patch

rvm install 2.2-head --patch cygwin.patch