Giter VIP home page Giter VIP logo

ry's Introduction

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.

ry's People

Contributors

ddazza avatar eregon avatar jneen avatar perlguy avatar robin850 avatar semmons99 avatar shanepelletier avatar zhm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.