简体   繁体   中英

Chruby install Ruby 1.8.7

I'm using chruby for version management and am cloning a project that is unfortunately in Ruby 1.8.7. Is it possible to install Ruby 1.8.7 with chruby? I'm having trouble finding resources for this process.

TL;DR

You can't, at least not using ruby-install . Ruby 1.8.7 is end-of-life , and support for it has been dropped by Postmodern's ruby-install tool.

Ruby 1.8.7 is Unsupported

The console error messages may vary depending on your installed libraries and compilers, but an unmodified Ruby 1.8.7 is unlikely to compile on more recent systems. For example, on Ubuntu 13.10:

$ ruby-install ruby 1.8.7
[lots of output elided]
math.c:37:13: error: missing binary operator before token "("
 #elif define(ERANGE)
             ^
make: *** [math.o] Error 1
!!! Compiling ruby 1.8.7 failed!

Why Ruby 1.8.7 is Unsupported

Support for Ruby 1.8.7 was dropped by Postmodern on December 9, 2013. Commit f013ed2 explains:

commit f013ed2476ecce82ea41ff63de413daf2231b82b
Author: Postmodern <postmodern.mod3@gmail.com>
Date:   Mon Dec 9 16:09:30 2013 -0800

    Drop support for Ruby 1.8.x since it has reached End-of-Life.

    * CVE-2013-4164 affects Ruby 1.8.x and there is no official patch.
      Enabling users to install and run 1.8.x at this point is irresponsible.

Alternatives

Your alternatives include:

  1. Upgrading to a newer stable version of Ruby such as Ruby 2.1.0 .
  2. Using a Ruby version manager such as RVM that, as of this writing, still supports Ruby 1.8.6-p420 and 1.8.7-p374.
  3. Use ruby-build instead of ruby-install. Follow the chruby instructions on using ruby-build in the README to make sure chruby can find the your newly-installed Ruby.
  4. Installing 1.8.7 manually somewhere that chruby can find it, and then using chruby to manage it.

We did remove all workaround patches and 1.8.x specific code in version 0.4.0 . However, if you are installing ruby 1.8.7 on an older system (with older versions of GCC, openssl, etc), it should still compile. 1.8.7 will not compile on newer systems with newer versions of GCC, openssl, etc. If you really need to install 1.8.7, you can try applying RVM's 1.8.7 patches with the --patch option; although running a heavily patched ruby is risky. Also, RedHat and Debian are still maintaining ruby 1.8.7 packages for their enterprise users.

You can use ruby-build which maintains a definition for MRI 1.8.7.

Then install 1.8.7 by doing:

ruby-build 1.8.7-p375 /opt/rubies/1.8.7-p375

The work around is to just install ruby with apt-get

apt-get install ruby

Next tell chruby to use the system ruby.

chruby system

For persistence add it to a ruby version file

echo 'system' > .ruby-version

Unfortunately chruby no longer supports 1.8.7. I have managed to make it working/running by installing 1.8.7 using rvm and linking it into ~/.rubies , like this:

\curl -sSL https://get.rvm.io | bash
rvm install 1.8.7-head
ln -s ~/.rvm/rubies/ruby-1.8.7-head ~/.rubies/ruby-1.8.7

If you are on OS X (10.11, El Capitan), you can install Ruby 1.8.7 using ruby-build in a way that chruby will be able to make use of it:

brew install ruby-build
brew install openssl libyaml libffi
brew install apple-gcc42
brew install openssl098

mkdir -p ~/.rubies

brew link openssl098 --force

ruby-build 1.8.7-p375 ~/.rubies/ruby-1.8.7

brew unlink openssl098

chruby 1.8.7

Reference: http://pawelgoscicki.com/archives/2015/12/installing-ruby-1-8-7-head-for-chruby-using-ruby-build-on-os-x-10-11-el-capitan/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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