1. RVM Gemsets + Bundler == Awesome

    14 June 2010

    So I’m going to assume that you’re already familiar with RVMGemsets and Bundler. If you don’t know about them please follow the links and read up.

    Mixing RMV Gemsets and Bundler together is a kickass way to maintain environment isolation for your projects. First you want to create a .rvmrc file in your project’s root directory. RVM will traverse up the directory structure until it finds a .rvmrc file and will use that.

    I usually just put the following into the file:

    rvm default@project_name

    This will change to my default ruby and set the gemset to ‘project_name’. Then I create a Gemfile and put all of my library dependencies in there. Then run:

    > bundle install

    Now I have a nice and isolated development environment. I can switch between multiple projects and always know that I won’t run into any versioning issues with the installed gems.

    One slight problem with this is if I’m including my .rvmrc file in my projects. Someone switches to it and get’s an error from RVM saying that the gemset doesn’t exist. Not that big a deal, they can go and create it. But it would be sweet if we could tell rvm to create the gemset if it doesn’t already exist.

    I pinged Wayne Seguin (the guy that wrote RVM) about this and he suggested the following solution:

    rvm --create use default@project_name

    tldr; RVM Gemsets  + Bundler == Awesome (and they kick ass)

    Update:
    That last .rvmrc will keep printing out the ruby@gemset being used after every directory change. Kind of annoying. So just suppress the output:

    rvm --create use default@project_name > /dev/null

Notes

  1. ntktgtym313 reblogged this from bcardarella
  2. gouthamvel reblogged this from bcardarella
  3. adimir reblogged this from bcardarella
  4. takkanm reblogged this from bcardarella
  5. bcardarella posted this