How to Make Ruby 1.9 the Default Ruby on Ubuntu

How do I make Ruby 1.9 the default Ruby on Ubuntu?

I'm not really sure, but maybe this can help:

update-alternatives --config ruby

... and here's the non-interactive, scriptable, way:

update-alternatives --set ruby /usr/bin/ruby1.9.1

You may find out about available alternatives and respective /usr/bin/... paths by doing:

update-alternatives --query ruby

Installing Ruby 1.9.1 on Ubuntu?

Save yourself the headache and use RVM (Ruby Version Manager)

Keep in mind, Rails 3 works best with Ruby 1.9.2. Ruby 1.9.2 fixes up quite a few bugs in 1.9.1 and is preferable to running 1.9.1.

With RVM installing 1.9.2 is a breeze.

Installed Ruby 1.9.3 with RVM but command line doesn't show ruby -v

You have broken version of RVM. Ubuntu does something to RVM that produces lots of errors, the only safe way of fixing for now is to:

sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh

open new terminal and validate environment is clean from old RVM settings (should be no output):

env | grep rvm

if there was output, try to open new terminal, if it does not help then restart your computer.

install RVM:

\curl -L https://get.rvm.io | 
bash -s stable --ruby --autolibs=enable --auto-dotfiles

If you find you need some hand-holding, take a look at Installing Ruby on Ubuntu 12.04, which gives a bit more explanation.

How to make JRuby 1.6 default to Ruby 1.9?

Use the JRUBY_OPTS environment variable. JRUBY_OPTS holds a list of arguments that are added to any arguments specified on the command line.

For example (on Linux):


$ jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (Java HotSp...
$ export JRUBY_OPTS=--1.9
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.9.2 trunk 136) (2011-01-10 769f847) (Java HotSpot(TM...
$ export JRUBY_OPTS=--1.8
$ jruby -v
jruby 1.6.0.RC1 (ruby 1.8.7 patchlevel 330) (2011-01-10 769f847) (Java HotSpo...

How to set default Ruby version with RVM?

If you put the RVM source line in your bashrc (in order to ensure that non-interactive shells have access to RVM), you will need to source .bashrc from your .bash_profile with the following as the last lines in your .bash_profile

if [ -f "$HOME/.bashrc" ]; then
source $HOME/.bashrc
fi

This pre-supposes that you have

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

in your $HOME/.bashrc. This is a good way to ensure that both interactive/login and non-interactive shells are able to find and load RVM correctly. Multi-User installs accomplish the same thing via the /etc/profile.d/rvm.sh file.

After that, you should have no problems defining a default Ruby to use via

rvm 1.9.2 --default

or

rvm use 1.9.2@mygemset --default

Its better to define a default gemset to use so as not to pollute your 'default' or 'global' gemsets.

If you are using non-interactive shells, be aware that they genereally operate in SH-compatibility mode which then requires you to set

BASH_ENV="$HOME/.bashrc"

in your $HOME/.profile in order you load RVM, or to set that within your script directly. The reason for this is that when bash is operating in SH mode it does not directly load .bash_profile or .bashrc as SH doesn't use those files, and bash is attempting to mimic the loading and execution process of the SH shell.

How do I install Ruby 1.9.3 on Ubuntu without RVM?

1st approach

Source

http://lenni.info/blog/2012/05/installing-ruby-1-9-3-on-ubuntu-12-04-precise-pengolin/

The new Ubuntu release has just rolled around and with it a slew of new packages. Personally, I'm tracking the development of Ruby quite closely but the default Ruby on Ubuntu ist still the 1.8 series which I can't recommend. Ruby 1.9 has some performance improvements and 1.9.3 in particular a lot of them compared to 1.9.2.

However, as I have elaborated in a previous post getting the Ruby 1.9 series on Ubuntu without using RVM instead of 1.8 isn't all that easy. Please read the post if you are interested in the details.

The short version is: You can get Ruby 1.9.3-p0 by installing the ruby-1.9.1 package. (The package is called 1.9.1 because that is the ABI version.)

If you want to make Ruby 1.9 the default do the following:

sudo apt-get update

sudo apt-get install ruby1.9.1 ruby1.9.1-dev \

rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 \ build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev

sudo update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.1 400 \
--slave /usr/share/man/man1/ruby.1.gz ruby.1.gz \
/usr/share/man/man1/ruby1.9.1.1.gz \
--slave /usr/bin/ri ri /usr/bin/ri1.9.1 \
--slave /usr/bin/irb irb /usr/bin/irb1.9.1 \
--slave /usr/bin/rdoc rdoc /usr/bin/rdoc1.9.1

# choose your interpreter
# changes symlinks for /usr/bin/ruby , /usr/bin/gem
# /usr/bin/irb, /usr/bin/ri and man (1) ruby


sudo update-alternatives --config ruby
sudo update-alternatives --config gem

# now try
ruby --version

If you want to make this your exclusive Ruby and get rid of Ruby 1.8 follow the uninstallation instructions.

Edit: I found out today that there also is a package called ruby1.9.3 however that is just a proxy package that doesn't have any files itself and only depends on ruby1.9.1. Aptitude confirms this:

Ruby uses two parallel versioning schemes: the `Ruby library compatibility version' (1.9.1 for this package), which is similar to a library SONAME, and the 'Ruby version' (1.9.3 for this package). Ruby packages in Debian are named using the Ruby library compatibility version, which is sometimes confusing for users who do not follow Ruby development closely. This package depends on the ruby1.9.1 package, and provides compatibility symbolic links from 1.9.3 executables and manual pages to their 1.9.1 counterparts.

There doesn't seem to be a rubygems1.9.3.

2nd approach

Also This link i found useful its very simple and effective.

http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/

Can't find Ruby 1.9.2 after installing RVM

RVM is a version manager which enables you to decide which of multiple installed Ruby versions you want to use in your current shell session. RVM does this by providing a shell function named rvm which can be used to switch between versions in the current session. This changes environment variables, especially the GEM_HOME and PATH, to match the currently selected Ruby installation.

Every installed Ruby version can be selected by a specific identifier string. If you had a system-wide Ruby installation already before you installed RVM, that one should be referenced by the string system. The newly installed version in your case should be called 1.9.2.

To make RVM work as intended, it is necessary to load the rvm shell function into your shell. How to do this is described in the RVM Installation Documentation in section 2 - "Load RVM into your shell sessions as a function".

You can see if the shell function is correctly loaded when the command type rvm | head -n1 responds with:

rvm is a shell function

If not correctly loaded it will tell you something like this:

rvm is /home/someone/.rvm/bin/rvm

If you finally have it working you can switch your active Ruby version with commands like rvm 1.9.2 or rvm system. You can get a list of all Ruby versions and their identifier strings recognized by RVM by the command rvm list.

You can also specify which Ruby version shall be enabled in all new shell sessions from the beginning by issuing the following command once:

rvm --default 1.9.2

Default ruby in server

After 8 hours of failed intents, this is what solved it:

All I had to do was configure Apache/Passenger again.

rvm use 1.9.2
gem install passenger --pre
passenger-install-apache2-module

followed the instructions to install apache. Then configured the file apache2.conf as told my the instructions before. Here I pasted the lines of code given in the instruction (and found out other lines that made reference to ruby1.8 so now the refer to ruby 1.9.2)

then restarted apache with

 sudo apache2ctl restart

thanks to this post but I didnt need to edit the vhost file (that I was unable to find) as suggested in the site, with reinstalling, adding the new lines and restarting apache solved the problem



Related Topics



Leave a reply



Submit