简体   繁体   English

在Cygwin上用RVM安装Ruby时遇到问题

[英]Trouble installing Ruby with RVM on Cygwin

I'm on Windows and I currently have Ruby v2.1.5 as that is what came with RailsInstaller. 我在Windows上,目前拥有Ruby v2.1.5,因为这是RailsInstaller附带的。 However, I need to downgrade to 2.1.1 for another project and I'm not sure how to. 但是,对于另一个项目,我需要降级到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 谢谢

You need to patch ruby soure code so it would compile on cygwin. 您需要修补ruby soure代码,以便可以在cygwin上编译。 Thankfully rvm supports patches out of the box! 幸运的是,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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM