• This repository has been archived on 04/Mar/2018
  • Stars
    star
    118
  • Rank 299,923 (Top 6 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 13 years ago
  • Updated over 8 years ago

Reviews

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

Repository Details

Minimal Ruby version management is minimal.

rbfu No Maintenance Intended

Deprecation Notice

rbfu has been deprecated (as of 2013-02-25). Please use chruby instead. Read my blog post for details.

Introduction

rbfu is a simple tool that manages multiple installations of Ruby and allows you to switch between them on the fly.

First and foremost, it supports an explicit invocation style that takes a Ruby version as a command line parameter or reads it from .ruby-version, if present:

$ rbfu @1.8.7 ruby -v  # switches to Ruby 1.8.7 and executes the command
$ rbfu ruby -v         # switches to Ruby version specified in .ruby-version

You can use rbfu-env to modify the current environment:

$ rbfu-env @1.8.7  # modifies current environment to use Ruby 1.8.7
$ rbfu-env         # same as above, but reads Ruby version from .ruby-version

And, of course, there's also an (optional) automatic mode that automatically modifies your shell session when you cd into a directory containing a .ruby-version file.

Rationale

Most Ruby developers like to keep different self-compiled versions of Ruby on their systems so they can switch back and forth between them depending on the project they're working on. Most of them use RVM to do this; others prefer rbenv. Both are great tools, but do a little bit too much for my taste.

See, the thing is: switching Ruby versions is actually a trivial operation, since it merely involves modifying a couple of environment variables (PATH, GEM_HOME and GEM_PATH). Both RVM and rbenv go through a lot of hassle in order to eventually perform this very simple operation.

rbfu is trying to keep things simple; it's a small shell script that doesn't do much else beyond changing the variables mentioned above.

I believe that software should be small and focused. rbfu doesn't come with support for gemsets (a feature I personally disagree with), nor will it compile Ruby for you (it's easy enough with ruby-build).

It just does one thing, and I think it does it really well.

If this appeals to you, please give rbfu a spin.

Installing rbfu

Using Homebrew

If you're on OS X and using Homebrew, you can install rbfu through the following command:

brew install http://git.io/rbfu.rb

Please don't forget to follow the instructions provided by the above command.

Manual Installation

If you're not using Homebrew, don't worry; installing rbfu is very straight-forward (and should work fine on Linux & friends, too).

  1. Download/clone the rbfu code and run the install script:

     git clone git://github.com/hmans/rbfu.git
     cd rbfu
     ./install.sh
    

    This will copy the rbfu executable to /usr/local/bin. If you need to install rbfu to a different directory, you can supply the PREFIX environment variable, manually copy bin/rbfu to a directory of your choosing, or add the provided bin directory to your PATH. Either way, all you need to do is make rbfu available in your $PATH.

  2. Add the following initialization line to a shell startup script of your choosing (eg. $HOME/.bash_profile):

     eval "$(rbfu --init --auto)"
    

    Or, if you don't want RVM-style automatic version switching (see below), leave out the --auto parameter:

     eval "$(rbfu --init)"
    

Installing Rubies

rbfu can switch between multiple installations of Ruby on the fly, and it expects them to live within directories named $HOME/.rbfu/rubies/$VERSION/. Feel free to install your favourite Ruby versions however you prefer to do it, but I recommend the excellent ruby-build tool.

Using ruby-build, here's how you'd install a bunch of popular Ruby versions:

ruby-build 1.8.7-p352 $HOME/.rbfu/rubies/1.8.7-p352
ruby-build 1.9.2-p290 $HOME/.rbfu/rubies/1.9.2-p290
ruby-build 1.9.3-p194 $HOME/.rbfu/rubies/1.9.3-p194

Obviously, each installed Ruby version will have its own self-contained set of gems and associated binaries, so go wild!

Usage

Basic Usage

First and foremost, rbfu is meant to be invoked explicitely, meaning that you can prefix your commands with rbfu, and it will make sure those commands run in an environment that is configured to use the specified version of Ruby.

The basic syntax looks like this:

rbfu [@<version>] <command>

A couple of examples:

rbfu @1.8.7 rake db:migrate
rbfu @jruby bundle install
rbfu @1.9.3 thin start

The @<version> parameter is optional; if not specified, rbfu will look for a file named .ruby-version (or, alternatively, .rbfu-version) in your current directory, followed by your home directory. This allows you to set global default for your user account, and project-specific overrides.

The .ruby-version files are expected to contain nothing but the Ruby version requested. For example:

echo "1.9.3-p0" > $HOME/.ruby-version
rbfu ruby -v    # will use 1.9.3-p0

If the @<version> parameter is given, it will always override whatever versions are specified in available .ruby-version files.

Modifying the current shell environment

Instead of prefixing all your commands with rbfu, you can use rbfu-env to reconfigure your current shell session. Example:

rbfu-env @1.9.3-p0

The above command will reconfigure your currently active shell session to use Ruby 1.9.3-p0. All commands run from within that session will use that version of Ruby, until the shell session is reconfigured again.

Note: rbfu-env is only available if the rbfu --init line has been added to your shell startup script, as described in the "Installation" section above.

Automatic Version Switching

If your shell startup script invocation of rbfu --init includes the --auto option (see "Installating rbfu"), rbfu will be configured to switch Ruby versions automatically when changing to a new directory containing a .ruby-version file.

(Also known as "works like RVM mode". Some people don't like this behavior, so it's optional -- simply remove the --auto option to disable this.)

Frequently Asked Questions / Tips & Tweaks

How do I assign shorter names to my Rubies ("1.8.7" instead of "1.8.7-p352")?

rbfu doesn't care what the directories your Rubies are installed in are named. You can install a version like 1.8.7-p352 into $HOME/.rbfu/rubies/1.8.7, and it will be available through rbfu @1.8.7.

How do I alias a Ruby version to a different name?

Simply symlink the directory.

ln -s $HOME/.rbfu/rubies/jruby-1.6.5 $HOME/.rbfu/rubies/jruby
rbfu @jruby

How do I create a new gemset?

RVM (a tool similar to rbfu) contains functionality to create completely separate sets of RubyGems (aka gemsets). rbfu does not contain such functionality, nor am I planning on adding it (I believe it's not neccessary; managing gem dependencies with Bundler works just fine, thank you very much.)

If you really want or need gemset-like functionality, you can emulate it by simply creating separate Rubies and using them in your projects (eg. $HOME/.rbfu/rubies/project_a/ and $HOME/.rbfu/rubies/project_b/). The overhead isn't all that bad.

How do I use rbfu with Pow?

Add a .ruby-version file to your project, as well as a .powrc file containing the following line:

source rbfu

This will make Pow start up your project through rbfu. We're working on adding built-in support for rbfu to Pow soon.

Why doesn't rbfu just install new Rubies itself?

This could be added easily (it's a simple invocation of ruby-build); however, I'm actively deciding against it because the most important design decision for rbfu is that it's supposed to do just one thing, and installing Rubies is not that thing.

Installing new Rubies is easy enough; in fact, if a requested Ruby version is missing, rbfu will print the command required to install it (using ruby-build).

Uninstalling

If you ever want to get rid of rbfu, make sure the @system Ruby is active, remove the rbfu line from your shell startup script, delete the rbfu executable (or run brew uninstall rbfu, if using Homebrew), reload your environment, and finally delete the $HOME/.rbfu directory.

rbfu-env @system
rm -rf $HOME/.rbfu/

Please note that this will also delete all Ruby versions managed by rbfu, including all of their installed gems. Destruction is fun!

Also, don't forget to remove the rbfu line from your shell startup script.

History

0.3.0

  • rbfu now also looks for .ruby-version files, using the same format as the .rbfu-version files supported previously. .ruby-version is being established as a common Ruby version specification format, with support being added to RVM, rbenv and other Ruby version managers.
  • zsh completion compatibility (thanks to @dbloete)
  • improved compatibility with bash < 4.0

0.2.0

  • First official release, featuring the new "@version" invocation style.

Contributors

License

MIT License

Copyright (c) 2011 Hendrik Mans

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

miniplex

A ๐Ÿ‘ฉโ€๐Ÿ’ป developer-friendly entity management system for ๐Ÿ•น games and similarly demanding applications, based on ๐Ÿ›  ECS architecture.
TypeScript
827
star
2

composer-suite

A suite of libraries for making game development with Three.js and React not only awesome, but so good, it would feel wrong to use anything else.
TypeScript
469
star
3

three-elements

Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. ๐ŸŽ‰
TypeScript
398
star
4

slodown

Markdown + oEmbed + Sanitize + CodeRay = the ultimate user input rendering pipeline!
Ruby
251
star
5

shader-composer

80
star
6

schnitzelpress

A lean, mean blogging machine for hackers and fools.
Ruby
77
star
7

statery

Surprise-Free State Management! Designed for React with functional components, but can also be used with other frameworks (or no framework at all.)
TypeScript
72
star
8

happy

A happy little toolkit for writing web applications.
Ruby
66
star
9

pants

PANTS: Distributed Social Blogging.
Ruby
64
star
10

controlfreak

Composable Game Input.
TypeScript
59
star
11

flutterby

A flexible, Ruby-powered static site generator.
Ruby
57
star
12

timeline-composer

Compose React timelines from <Repeat>, <Delay> and <Lifetime>.
19
star
13

eventery

Super-lightweight event class implementation. ๐Ÿš€
TypeScript
19
star
14

Godot-RigidBody-Auto-Scaler

Want to scale rigidbodies in Godot? Now you can. ๐Ÿš€
GDScript
17
star
15

allowance

Allowance is a general-use permission management library for Ruby. It's decidedly simple, highly flexible, and has out-of-the-box support for ActiveModel-compliant classes.
Ruby
16
star
16

space-scene-sandbox

TypeScript
15
star
17

indiepants

IndiePants, aka Pants Phase 2. A clean indieweb-like implementation.
Ruby
13
star
18

hamburg-io

A hub for the Hamburg tech community.
Ruby
10
star
19

trinity

TypeScript
9
star
20

trinity-legacy

TypeScript
7
star
21

create-react-game

JavaScript
7
star
22

godot-survival-guide

Assorted Workarounds and Dirty Hacks for Stuff That's Missing, Broken, or Otherwise Weird in the Godot Engine
7
star
23

things

TypeScript
7
star
24

signal

TypeScript
6
star
25

react-game-starter

TypeScript
5
star
26

bigby-legacy

TypeScript
5
star
27

crankypants

A thing that does things.
Crystal
5
star
28

Godot-ParticlesPortal

GDScript
4
star
29

spacerage-one

Dumb little web-based space shootybang. (Yes, that's an actual genre.)
CoffeeScript
4
star
30

material-composer

4
star
31

awesome-freelancing-germany

Nรผtzliche Ressourcen fรผr Freelancer in Deutschland.
4
star
32

three-vfx-starter

JavaScript
4
star
33

supermutant

EMBRACE THE MUTATION and turn any JavaScript object into a SUPERMUTANT REACTIVE STATE CONTAINER. UUUAAAAAHHHHHHHHHHHRRRRRR
TypeScript
4
star
34

lit-shootybang

JavaScript
3
star
35

schnitzelpress-skeleton

Schnitzelpress Skeleton App. Clone/fork/download this as a base for your own Schnitzelpress powered blog.
Ruby
3
star
36

solid-trinity

TypeScript
3
star
37

spacerage.liveview

Phoenix + LiveView + three-elements = ?
Elixir
3
star
38

spacerage.6dof

Space pew pew using react-three-fiber.
TypeScript
3
star
39

fantasy-js-physics-engine

2
star
40

hmansify

Some stuff from my home directory.
Ruby
2
star
41

happy-resources

A collection of resource-focused controllers for the Happy Web Application Toolkit.
Ruby
2
star
42

ingrid

Spatial Hash Grids and not much else.
TypeScript
2
star
43

bumpy

Bumpy bumps your gem's version number.
Ruby
2
star
44

webmade.games

https://webmade.games
Astro
2
star
45

hmans_me

My blog, as seen on http://hmans.io. Powered by Flutterby.
CSS
2
star
46

randomish

TypeScript
2
star
47

render-composer

2
star
48

flutterby-website

The official website for Flutterby.
Ruby
2
star
49

indiepants-docker

Docker & Fig configuration for painless IndiePants deployment.
2
star
50

playground

A collection of experimental react-three-fiber tools and toys that aren't quite ready to be released as their own packages.
JavaScript
2
star
51

particulous

A playground for exploring patterns around CPU-based particle systems.
TypeScript
2
star
52

shadenfreude-planet

Created with CodeSandbox
TypeScript
2
star
53

bevy-mrp-macos-performance

Rust
2
star
54

panties

Command line client for #pants.
Ruby
1
star
55

happy-helpers

[Deprecated!] View helpers for your custom Rack app or framework.
Ruby
1
star
56

publicbox

Serves JSON indices of your favorite public Dropbox folders.
Ruby
1
star
57

resourcery

It's resource sorcery! Or something.
Ruby
1
star
58

imaginary

Client gem for Imaginary.
Ruby
1
star
59

happy-cli

Command line tool for the Happy web application toolkit.
Ruby
1
star
60

xml-muncher

TypeScript
1
star
61

Godot4-Node-Performance

GDScript
1
star
62

twotter

TWOTTER ๐Ÿฆ† - a little playground app for my Ruby on Rails trainings.
Ruby
1
star
63

glowlayer

Experimental Glow Layer for Three.js
JavaScript
1
star
64

compass-naked

An experimental Rack-only app I'm using to find the easiest way to integrate Compass with Tilt.
Ruby
1
star
65

trinity-examples

A collection of examples for (and experiments with) the Trinity framework.
JavaScript
1
star
66

schnitzel-rails-template

The Team Schnitzel Rails application template. \o/
Ruby
1
star
67

schnitzelpress-org

The source code for schnitzelpress.org.
Ruby
1
star
68

splodybox

A VFX/R3F demo
JavaScript
1
star
69

spacerage

TypeScript
1
star
70

schnitzelstyle

A tiny, light-weight, hopefully sane CSS framework with a Schnitzel flavor.
Ruby
1
star
71

hmans_net

My personal weblog, powered by SchnitzelPress (www.schnitzelpress.org)
Ruby
1
star
72

three-increments

TypeScript
1
star
73

fun-with-kittehs-presentation

Fun With Kittehs. Yeah.
1
star
74

learn-bevy-cube-of-cubes

Rust
1
star