Skip to content

Instantly share code, notes, and snippets.

@jbinto
Created May 5, 2015 19:21
Show Gist options
  • Select an option

  • Save jbinto/7ca227b3118e2a83ef7c to your computer and use it in GitHub Desktop.

Select an option

Save jbinto/7ca227b3118e2a83ef7c to your computer and use it in GitHub Desktop.

Revisions

  1. jbinto created this gist May 5, 2015.
    69 changes: 69 additions & 0 deletions ruby-versions-chruby.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    # Dealing with Ruby versions - chruby

    Every time I sit down to code, it seems like a new Ruby version is available.

    When I first learned ruby I used [rvm](https://rvm.io/) on my Mac. In production on linux, I use [rbenv](https://github.com/sstephenson/rbenv), likely due to its Capistrano integration.

    When I set up my current machine, I found `rvm` had fallen out of fashion in favour of something called `chruby`.

    ## Install new ruby

    Install `ruby-install` and `chruby` from Homebrew, if not already done.

    ```
    brew install chruby --HEAD
    brew install ruby-install --HEAD
    ```

    Go to https://www.ruby-lang.org/en/ and find out the newest version. At the time of writing, that is `2.2.2`.

    ```
    ruby-install ruby 2.2.2
    ```

    ## Remove old Rubies

    Remove older Ruby versions:

    ```
    ls -la ~/.rubies
    rm -rf ~/.rubies/ruby-2.1.5
    rm -rf ~/.rubies/ruby-2.2.1
    ```

    ## Housekeeping

    Restart your shell, so `chruby` can see other versions.

    Update `.bashrc` (read: `.zshrc`, or `.common_env` in my case) to execute the correct `chruby` command.

    Also update `.powconfig` if using Pow.

    ```
    chruby 2.2.2
    ```

    ## Gems/bundler

    Bundler will not be installed, and rubygems may be out of date:

    ```
    $ bundle
    zsh: command not found: bundle
    $ gem --version
    2.4.5
    ```

    Upgrade rubygems, and install bundler.

    ```
    gem update --system
    gem install bundler
    ```

    ## "Gemsets"

    `chruby` doesn't have a concept of "gemsets". This is not like Python's `virtualenv` where each project is isolated from one another.

    Every project will need to be re-bundled. Gems are installed locally, for the current `chruby` version.