Chruby install Ruby 1.8.7 - ruby

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.

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.

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:
Upgrading to a newer stable version of Ruby such as Ruby 2.1.0.
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.
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.
Installing 1.8.7 manually somewhere that chruby can find it, and then using chruby to manage it.

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/

Related

installing RubyGem on CentOs 5

My ultimate goal is to install Sass.
To do this I need to install RubyGems
To do this I need to install Ruby.
I installed Ruby with yum.
I then tried to install gem with yum yum install rubygem
The response is "nothing to do" and yet when I write gem install sass I get:
gem: command not found
I decided to try to install rubygems 2.2.2 manually. After downloading it, I tried to run ruby setup.rb and in response I get:
Rubygems now requires Ruby 1.8.7 or later
But yum does not seem to be able to install anything later than 1.8.5.
So now I'm trying to do this manually.
I downloaded Ruby 1.9.2 to my home directory and followed these instructions: http://howboring.com/post/1226760251/centos-5-and-rails-3-and-ruby-1-9-2
This seems to work, but the problem is ruby1.9.2 is installed in my home directory (i.e. ~/ruby1.9.3 not system wide.
Thus in the directory where I installed ruby 1.9.2 ruby -v still gives 1.8.5 but ./ruby -v returns 1.9.2. And which ruby returns /usr/bin/ruby (I suppose I could replace this with a symlink that points to ~/ruby1.9.2/ruby but this doesn't seem like a "best practice")
So my main question is where should install ruby 1.9.2 with Root Permissions so that 1.8.5 is replaced with 1.9.2 system wide.
My corollary question is: is there any easier way to do this? (perhaps install sass without install rubygems??)
I then tried to install gem with yum yum install rubygem
You have a typo in the package name, it is actually named rubygems.
Can i suggest Wayne Seguins excellent rvm (ruby version manager). As the home page states:
"RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems".
Site has comprehensive installation instructions. I've posted a truncated Set of instructions for installing on POSIX systems below, but please refer to the projects' home page as:
"we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods."
Install RVM (development version):
\curl -sSL https://get.rvm.io | bash
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
user$ source ~/.rvm/scripts/rvm
test the installation was successful:
user$ type rvm | head -n 1
this should output "rvm is a function"
List all known rubies:
rvm list known //this will output a large list of rubies shortened here
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-p374]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p320]
[ruby-]1.9.3[-p545]
[ruby-]2.0.0-p353
[ruby-]2.0.0[-p451]
[ruby-]2.1[.1]
[ruby-]2.1-head
ruby-head
...
install the version you want:
rvm install 1.9.2
You can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:
rvm use 2.1 --default
You can also temporarily use another version of your ruby versions
rvm list known //lists system available rubies
Choose to use another ruby
rvm use 1.9.3
RVM is a great tool, well documented, and actively developed, it handles a wider scope of functionality than i can list here, and it's a tool I use everyday.
You can use rbenv to install ruby and rubygems that you need
https://gist.github.com/jpfuentes2/2002954

Why is reinstalling Ruby 1.8.7 failing

I tried to reinstall Ruby 1.8.7 using RVM after having troubles with Homebrew. I reinstalled Homebrew and RVM, and I have Ruby 1.9.3 and 2.0.0 working fine.
One of my projects uses 1.8.7 so when I used:
rvm install 1.8.7
I got:
The requested url does not exist(22):'http://production.cf.rubygems.org/rubygems/rubygems-2.0.9.tgz'
Checking fallback: ftp://production.cf.rubygems.org/rubygems/rubygems-2.0.9.tgz
Checking fallback: http://www.mirrorservice.org/sites/production.cf.rubygems.org/rubygems/rubygems-2.0.9.tgz
No fallback URL could be found, try increasing timeout with:
echo "export rvm_max_time_flag=20" >> ~/.rvmrc
There has been an error while trying to fetch rubygems.
Halting the installation.
I tried to do:
rvm get stable
rvm get head
curl -L get.rvm.io | bash -s stable
Which I found on another Stack Overflow question with a similar error, but it's obviously a bit different.
I run:
RVM 1.22.9 (stable)
Homebrew 0.9.4
Mac OSX 10.8.4
This was an issue with rubygems release process - https://github.com/wayneeseguin/rvm/issues/2212 and https://github.com/rubygems/rubygems/issues/651
For next time it happens you can specify which version of rubygems to use when installing ruby with rvm like this:
rvm install 1.8.7 --rubygems 2.0.8
I'm seeing essentially the same error with a chef deploy of rvm under ubuntu - ruby 1.8.7 refuses to complete installation (the ruby is there, but no gem, etc) due to a problem with 'rubygems-2.0.9.tgz'
Edited to add - if you run 'rvm rubygems 2.0.7' (latest that seems to be really available right now) it seems to work.

Ruby 1.9.3 Not overriding 1.9.1 gems

I am using Ubuntu 12.04 and I have system default ruby 1.8 and 1.9.1 and 1.9.3. The problem is that I do manage to switch to 1.9.3 but not the gems for the 1.9.3 and by default system is using the 1.9.1 gems. This causes a lot of errors while using the rails and other ruby libs which are dependent on the 1.9.3.
I tried to use
sudo update-alternatives --config ruby
sudo update-alternatives --config gems
and it doesn't offered me to choose 1.9.3 gems but only managed to switch the ruby interpreter. I tried rbenv and rvm but no use. While using the rails and the shoes, I get plenty of errors related to the gems of 1.9.1.
Also when I use the switch with rvm, it asks me to install ruby 1.9.3 which is already installed but doesn't show up for rvm and rbenv.
Is there something wrong with ruby on this system?
you might be confusing compatibility level with the real ruby version, all ruby 1.9.x will have 1.9.1 in their paths - it is the intended behavior.
using rvm you can mount system installed rubies:
rvm automount
OR:
rvm mount /path/to/bin/ruby193 -n system193
but those system rubies might have some extra configuration that can make them not to work well with RVM, you might be better with just installing fresh ruby:
rvm get head
rvm requirements # make sure to read it
rvm use 1.9.3 --install
if you care for performance and value your time you an use falcon patch and compilation on more cores:
rvm install 1.9.3 --patch falcon -j 3
rvm use 1.9.3

Why does rvm install ruby not work?

It is said on the Rails 3.2.9 blog that Ruby 1.9.3-p327 is recommended to be installed. But
rvm install ruby-1.9.3-p327
actually gives an error, and the log says:
There is no checksum for
'http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.bz2' or
'ruby-1.9.3-p327.tar.bz2', it's not possible to validate it. If you
wish to continue with unverified download add '--verify-downloads 1'
after the command.
But I checked http://ftp.ruby-lang.org/pub/ruby/1.9/ and the ruby-1.9.3-p286 has the same files as the p327. So where is the checksum located? Is it inside of the .bz2 file? So how should we install p327, is it just by
rvm install 1.9.3-p327 --verify-downloads 1
and is there security concerns, or are there other methods to install it safely?
First thing, make sure that your rvm version knows about this version by running rvm list known
On my machine, when I ran it the first time I got the following output for known MRI Rubies:
$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7-p370
[ruby-]1.8.7[-p371]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2-p180
[ruby-]1.9.2-p290
[ruby-]1.9.2-p318
[ruby-]1.9.2[-p320]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3-p0
[ruby-]1.9.3-p125
[ruby-]1.9.3-p194
[ruby-]1.9.3-[p286]
[ruby-]1.9.3-head
ruby-head
So my version of rvm only knew about 1.9.3-[p286] as the most recent version 1.9.3 version.
I got the latest version of rvm with the following command:
$ rvm get stable
After that, the list of known MRI rubies was as follows:
$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7-p370
[ruby-]1.8.7[-p371]
[ruby-]1.9.1[-p431]
[ruby-]1.9.2-p180
[ruby-]1.9.2-p290
[ruby-]1.9.2-p318
[ruby-]1.9.2[-p320]
[ruby-]1.9.2-head
[ruby-]1.9.3-preview1
[ruby-]1.9.3-rc1
[ruby-]1.9.3-p0
[ruby-]1.9.3-p125
[ruby-]1.9.3-p194
[ruby-]1.9.3-p286
[ruby-]1.9.3-[p327]
[ruby-]1.9.3-head
[ruby-]2.0.0-preview1
ruby-head
A related thread on the rvm googlegroups discussion forum
In ubuntu 12.04, I use the cmd as follows, the newest version "-p327" will automatically detected and installed:
rvm install 1.9.3
The guide Installing Rails on Ubuntu 12.04 with RVM support may helps:

install bundler using rvm, ruby 1.8.7 with gcc 4.7 on linux

Issues building ruby 1.8.7 or installing the bundler gem with GCC 4.7 on linux (Fedora 17, Arch, etc.). This issue occurred for me using RVM. I was able to install 1.8.7, but unable to install the bundler gem. I would receive the following error:
$ gem install bundler
~/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/timeout.rb:60: [BUG] Segmentation fault
ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux]
this issue is described in a number of locations, including:
ruby-enterprise 1.8.7-12: timeout.rb:60: [BUG] Segmentation fault
Ruby gem install is seg faulting
rvm install rbx fails on archlinux (mri 1.8 + gcc 4.7 issue)
ruby1.8: segfaults when compiled with gcc-4.7
Ruby 1.8.7 fails to build (Arch Linux, gcc > 4.6)
The description of the problem in the links in the original question suggest installing older versions of gcc to build 1.8.7, this is not necessary.
$ rvm remove 1.8.7
$ CFLAGS="-O2 -fno-tree-dce -fno-optimize-sibling-calls" rvm install 1.8.7
$ rvm use 1.8.7
$ gem install bundler
Solution derived from the following:
Bug #6383: Segfault in Timeout module when compiled with GCC 4.7
Also, I would ensure that you have the stable release that was released as of today, May 30, 2012 which is 4.7.0 and NOT one of the previous 4.7 releases which were not stable releases. RVM has a policy of not supporting non-stable-releases (aka development versions) of GCC for the reason that, well we're not compiler guys hehe.
Then, in addition, please uninstall and reinstall your original version of 1.8.7. Another option is to 'rvm reinstall 1.8.7' though not all previous configure options may be regenerated to include acceptance of the changed CFLAGS variable, as written to the config. #mpapis, do we need to advocate use of the --autoconf --force here?
(mpapis and I are devs on the RVM Project so this is as good a place as any to discuss flags and monitor to see which should be done so we can push the info to anyone else that comes to us about this)

Resources