Ruby 1.9.3 Not overriding 1.9.1 gems - ruby

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

Related

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.
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/

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

Can I install Ruby v1.8.7 in System(not in rvm) after installing ruby in RVM 1.9.3

Actually, I have to work on Chef which use system default ruby v 1.8.7.
and with rvm installed ruby my Chef is not wroking.
So , To make my chef server installation. I required to have ruby1.8.7 into my system.Before I was using ruby 1.9.3 for my project(via RVM).
Can anybuddy tell , How can I install Ruby v1.8.7 in System(not in rvm) after installing ruby in RVM 1.9.3 .
Or is it possible or not?
you want to set a default ruby:
rvm use 1.8.7 --install --default
This will install ruby 1.8.7 if not installed, it will use it and set as default, so any time rvm is loaded - you will have access to it.
it is possible but to be honest you are better with RVM, in this way you can have control over your machine
rvm use system tells rvm to leverage a system install of Ruby. To set system Ruby as default, type rvm reset.
Use the package manager of your distribution, that's what rvm system is about - giving control back to your system.

Which ruby version is installed?

Sounds strange but I cannot tell which ruby version is installed. If I do
rvm rubies
I get
ruby-1.9.2-p180 [ i686 ]
but with
ruby -v
I get
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux]
When trying to
rvm upgrade 1.8.7-p302 1.9.2-p180
I get an error
ERROR: Ruby 'ruby-1.8.7-p302' is not installed - please install it first.
ERROR: Error migrating gems.
So, which one is it? 1.8.7-p302 or 1.9.2-p180 ???
Please help me out here! Thanks
You get 1.8.7 from the installed version of your system. Use rvm use --default 1.9.2 in order to set the Ruby installed via rvm as default.
RVM basically changes your $PATH variable to point to a different Ruby version than the one installed on your system.
Please also make sure that you have done steps 2 and 3 of the installation guide and confirmed that RVM is correctly set up.
You might have 1.8.7 because you did sudo apt-get install ruby or something like that, and then later ran rvm install 1.9.2. Is that the case?
The answer is both as mentioned by other posters. As a recommendation you should uninstall the ruby packages that come with the system if you choose to manage ruby version using rvm.

I'm confused, what's the easiest way to install Ruby 1.9.2 on OS X?

My current version is ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]
Step 1. Install Homebrew: https://github.com/mxcl/homebrew
This enables you to install various *IX projects on a mac. You may need to install xcode as part of this, so you may need your OS X disc to hand. Homebrew is useful for many other things - a good thing to have installed anyway.
Step 2. Install Ruby Version Manager:
brew install rvm
Step 3. Install whichever Ruby version you want. This means you can have multiple Ruby installations (with their own sets of rubygems) running independently of one another. for 1.9.2 try this:
rvm install 1.9.2
If you get a 'readline' error, try this:
rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
You should now be able to do this to test your ruby version:
ruby --version
To switch back to another version of ruby, just use the rvm command.
You can try rvm to install whatever the version of ruby.
if you will get error
undefined method `path' for Gem:Module (NoMethodError)
during command
~/rubygems-1.3.7 $ ruby setup.rb
remove ruby and rubygems with command
sudo autoremove ruby
sudo autoremove rubygem
ant try to install all again

Resources