• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 12 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The simplest ruby version manager

ry: the simplest ruby virtual env

Installation

If you're on a Mac with homebrew installed, you may simply brew install ry and follow the instructions.

Otherwise, install the files from the repo to your favorite prefix (I use ~/.local, which is the default).

git clone git://github.com/jneen/ry
cd ry
PREFIX=$HOME/.local make install

and add the following lines to your bashrc (or zshrc):

# If you're using the default ~/.local prefix,
# make sure ~/.local/bin is on your $PATH.
export PATH="$HOME/.local/bin:$PATH"
eval "$(ry setup)"

or, if you don't like eval, you can do it manually:

export PATH="$PREFIX/lib/ry/current/bin:$PATH"

For ZSH completion, see this.

If you want to specify a different directory for installing rubies:

# rubies are installed into $RY_PREFIX/lib/ry/rubies
# set RY_RUBIES for an alternate location
export RY_RUBIES="$HOME/.rubies"

Usage

Ry is a bit different from other version managers. The major design goal of ry is to be explicit, unobtrusive, and easy to query. In the vein of the n package manager for node, there are no subshells, and the only thing it needs to add to your environment is a single entry to your $PATH (also tab completion if you like). For example, here's how you create a new installation:

ry install http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz mri-1.9.3

This creates an installation of Ruby called mri-1.9.3 using the tarball from ruby-lang.org. To switch to this ruby, use

ry use mri-1.9.3 # or: ry mri-1.9.3

Want to use a custom commit?

ry install https://github.com/ruby/ruby/tarball/<hash> mri-custom

ruby-build

If you have ruby-build installed, you can use it very easily with ry:

ry install 1.9.3-p125

shell-local ruby selection

Because ry use changes a symlink, that ruby is globally activated across all shells. To use a shell-local ruby, simply set your $PATH to include that ruby's bin dir. The easiest way to do this is to use the ry fullpath <ruby> helper, which outputs a copy of your $PATH variable modified for use with ry.

export PATH="$(ry fullpath my-cool-ruby)"

You can activate this automatically with something like direnv.

For more information, see ry help.

Developing

All of the magic is in the bash script bin/ry. Here are a couple of bash features I use that aren't common elsewhere:

  • Poor man's namespacing - the character : is a perfectly valid character to use in a bash function's name. All of ry's subcommands are implemented as functions looking like ry::foo. At the bottom of the file is the function ry which essentially delegates to ry::$1 - so to add a new subcommand, all you need to do is define the bash function and document it in ry::usage.

  • Piping from heredocs is awesome. The syntax cmd <<<"$variable" runs cmd with stdin as the content of $variable. I use this extensively, and you should too.

More Repositories

1

parsimmon

A monadic LL(infinity) parser combinator library for javascript
JavaScript
1,240
star
2

balls

Bash on Balls
Shell
858
star
3

pjs

Classes for javascript that don't suck.
JavaScript
195
star
4

python-cache

Caching for humans
Python
63
star
5

variants-slides

Slides for "Variants are Not Unions", a talk given at Clojure Conj 2014
Clojure
16
star
6

ragel.vim

My "fork" of Adrian Thurston's syntax file
Vim Script
15
star
7

mock_redis

A little class that acts like redis-rb, but for testing on machines without redis.
Ruby
14
star
8

express-handlebars

Handlebars integration for express
JavaScript
13
star
9

color.js

The missing color library
JavaScript
9
star
10

tnetstrings-js

A tnetstrings parser for javascript (browser or node)
CoffeeScript
9
star
11

cinch-test

A testing module for the cinch IRC framework
Ruby
8
star
12

ixl-prototype

A prototype of the ixl language.
Haskell
7
star
13

eco.vim

Vim syntax highlighting for eco, embedded coffeescript DEPRECATED: see https://github.com/kchmck/vim-coffee-script/blob/master/syntax/eco.vim
Vim Script
7
star
14

rpgem

The gem-to-rpm converter, done right
Ruby
5
star
15

lolgebra

A chat framework where you can lol in math!
Ruby
5
star
16

iplogic

IPv4 swiss army chainsaw.
Ruby
5
star
17

math-tau

Ruby
4
star
18

ix

a lightweight, easily configurable modal editor
4
star
19

jim-ncurses

ncurses bindings for jimtcl
C
4
star
20

back

A middleware framework for bash CGI scripts
Shell
4
star
21

rudis

An extensible OO redis client for ruby
Ruby
3
star
22

dot

my dotfiles
Vim Script
3
star
23

thunk.js

A generator for trampoline-evaluated recursive algorithms.
JavaScript
3
star
24

netherpad

An online, plugin-friendly, shared document in node (wip)
3
star
25

netherquill

Share documents!
3
star
26

nathans-university-jayferd

Exercises for Nathan's University courses.
JavaScript
3
star
27

tweet.sh

a twitter client implemented in bash
Shell
3
star
28

express-contrib

Express framework utilities
JavaScript
3
star
29

cube

A Rubik's Cube emulator in Haskell, for testing solving algorithms and such.
Haskell
3
star
30

class.sh

Classical OO for bash (yeah you heard me)
Shell
2
star
31

workqueue

a dirt-simple in-process aggregating workqueue for parallel processing in Ruby.
Ruby
2
star
32

node-named-routes

framework-agnostic named routes for node
JavaScript
2
star
33

clojure-west-2015-slides

Groff
2
star
34

thankful_eyes.vim

A vim port of Thankful Eyes, the Gedit color scheme
Vim Script
2
star
35

ringo

the redis recipe framework
Ruby
2
star
36

wrappable

Generic module for a wrappable class
Ruby
2
star
37

tnetstrings-ruby

A ruby extension to parse and dump tnetstrings
C
2
star
38

cacher

A handy Ruby caching library with pluggable backends.
Ruby
2
star
39

stl-tulip-slides

Vim Script
2
star
40

lolgebrajs

In javascript, this time.
JavaScript
1
star
41

trello-skeletons-talk

Vim Script
1
star
42

synth

Ruby
1
star
43

smartbot

Scala
1
star
44

karel

the littlest robot
1
star
45

truth

Ruby
1
star
46

resume

my résumé
1
star
47

sokoban

an old try at a Ruby Quiz
Ruby
1
star
48

haskell-friends

my little "learning haskell" puzzle
Haskell
1
star
49

blog

a blag
JavaScript
1
star
50

ixl-rust

The ixl language, in rust this time.
Rust
1
star
51

jneen.net

My blag, based on jneen/blag
Ruby
1
star
52

plans

A clone of Grinnell Plans for general-purpose use
Ruby
1
star
53

gnome-terminal-ThankfulEyes

The Thankful Eyes theme for gnome-terminal
Shell
1
star
54

hilite.tex

shellout and syntax highlighting system for tex
TeX
1
star
55

better-schedule-search

Berkeley's schedule search sucks. We mashed it up and made it better. Now we're porting it to Sinatra.
Ruby
1
star
56

jayferd.github.com

JavaScript
1
star
57

core_ext

Things I Think Ruby Should Do For You
Ruby
1
star
58

money

a simple expense-sharing app
Ruby
1
star