Difference between revisions of "RVM"

From DiLab
Jump to: navigation, search
Line 1: Line 1:
{{TocRight}}
{{TocRight}}
Ruby Version Manager - ļauj veidot neatkarīgas vides dažādām ruby, gems, rails u.c. versijām.
[http://rvm.beginrescueend.com/ Ruby Version Manager] - allows switching between versions of ruby, gems, rails etc.


== RVM installation ==
Galvenā saite: http://rvm.beginrescueend.com/

First install [http://rvm.beginrescueend.com/ RVM (Ruby version manager)].
This will download the source and compile the necessary tools,
and will also allow to switch between different versions, for example, ruby-1.8 and ruby-1.9.2.


RVM instalācija (paskatamies arī komentārus par .bashrc un return):
sudo apt-get install curl git-core
sudo apt-get install curl git-core
<nowiki>bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )</nowiki>

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
RVM tells you to update your .bashrc. Add the following at the end of the file:

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

RVM is also concerned if you have any 'return' in your .bashrc script.
Replace it using if and fi as in the RVM comments after its installation. Comment the first line below and add the second. Then acc fi at the end of the file.

# [ -z "$PS1" ] && return
<nowiki>if [[ -n "$PS1" ]] ; then</nowiki>


== Konfigurāciju vadība ==
== Configuration management ==


How to see the current configuration
Kā paskatīties tekošo
rvm use
rvm use


How to switch to the default configuration
Kā pārslēgties uz noklusēto konfigurāciju
rvm use system
rvm use system


pārslēgties uz citu (1.9.2@rails3) konfigurāciju
How to switch to another (1.9.2@rails3) configuration
rvm use 1.9.2@rails3
rvm use 1.9.2@rails3


radīt jaunu (1.9.2@rails3) konfigurāciju
How to create a new (1.9.2) configuration with a (rails3) gemset
rvm use --create 1.9.2@rails3
rvm use --create 1.9.2@rails3


== Piemērs videi: Ruby 1.9.2 un Rails 3 ==


=== Instalējam Ruby 1.9.2 ===
== Example: set up Ruby 1.9.2 and Rails 3 ==

=== Install Ruby 1.9.2 ===
rvm 1.9.2
rvm 1.9.2


Izveido Rails 3 gemset un pārslēdzamies uz to:
Create Rails 3 gemset and switch to it:
rvm use --create 1.9.2@rails3
rvm use --create 1.9.2@rails3


=== Instalējam gemus (datubāzes) ===
=== Install gems (databases) ===

* sqlite3
* sqlite3
sudo apt-get install sqlite3
sudo apt-get install sqlite3
Line 40: Line 54:
gem install mysql
gem install mysql


* postgres (jaunākais gems saucās pg, nevis postgres!)
* postgres (note, the newer gem is "pg", not "postgres"!)
sudo apt-get install postgresql-server-dev-8.4
sudo apt-get install postgresql-server-dev-8.4
gem install pg
gem install pg


=== Instalējam pārējos gemus pēc garšas ===
=== Install the other gems as needed ===


gem install ... (tie, ko vēl vajag)
gem install ... (tie, ko vēl vajag)


=== Instalējam Rails 3 ===
=== Install Rails 3 ===
gem install rails
gem install rails
rails --version
rails --version


...vai bez "ri" un dokumentācijas (ātrāk)
...or without "ri" and "rdoc" documentation (faster)
gem install rails --no-ri --no-rdoc
gem install rails --no-ri --no-rdoc



== More about Rails==
== More about Rails==

Revision as of 17:26, 28 December 2010

Ruby Version Manager - allows switching between versions of ruby, gems, rails etc.

RVM installation

First install RVM (Ruby version manager). This will download the source and compile the necessary tools, and will also allow to switch between different versions, for example, ruby-1.8 and ruby-1.9.2.

sudo apt-get install curl git-core
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

RVM tells you to update your .bashrc. Add the following at the end of the file:

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

RVM is also concerned if you have any 'return' in your .bashrc script. Replace it using if and fi as in the RVM comments after its installation. Comment the first line below and add the second. Then acc fi at the end of the file.

# [ -z "$PS1" ] && return
if [[ -n "$PS1" ]] ; then

Configuration management

How to see the current configuration

rvm use

How to switch to the default configuration

rvm use system

How to switch to another (1.9.2@rails3) configuration

rvm use 1.9.2@rails3

How to create a new (1.9.2) configuration with a (rails3) gemset

rvm use --create 1.9.2@rails3


Example: set up Ruby 1.9.2 and Rails 3

Install Ruby 1.9.2

rvm 1.9.2

Create Rails 3 gemset and switch to it:

rvm use --create 1.9.2@rails3

Install gems (databases)

  • sqlite3
sudo apt-get install sqlite3
gem install sqlite3-ruby
  • mysql
sudo apt-get install mysql
gem install mysql 
  • postgres (note, the newer gem is "pg", not "postgres"!)
sudo apt-get install postgresql-server-dev-8.4
gem install pg

Install the other gems as needed

gem install ... (tie, ko vēl vajag)

Install Rails 3

gem install rails
rails --version

...or without "ri" and "rdoc" documentation (faster)

gem install rails --no-ri --no-rdoc


More about Rails

More about Rails3