Ask A Question

Notifications

You’re not receiving notifications from this thread.

Any good tutorials on using rbenv?

tquill asked in General

I setup my rails environment using the ubuntu installation guide found on gorails (amazingly helpful, thank you) but I'm not really sure how to use rbenv.

I have a few rails apps, and I'm wondering how to manage their gems using rbenv. I've cloned a few older apps into my sites directory and I've broken a few things here and there with "Gem::LoadError" popping up saying "You have already activated rake 10.5.0, but your Gemfile requires rake 10.4.2" as an example.

I've looked at the rbenv github and I'm still a bit confused.

I guess my first basic questions would be...

1) If I'm installing a new gem in one of my apps... is there anything special I need to do with rbenv to keep that gem segregated to that app?

2) If I'm creating a new app... anything special I need to do with rbenv?

3) If I'm cloning an app into my sites directory... anything special I need to do with rbenv? As a side question to this... I'm supposed to delete the gemfile lock right?

Thanks for any help.

Reply

Also maybe how to restart fresh with all of my gems (but keeping my current apps working)?

Reply

These are really good questions

1) Nope, bundler will do that for you. However, there will be a global default, so that's why you get the rake error and why you want to run bundle exec rake whatever instead of just rake whatever. Bundler handles this separation for you.

2) Not a thing. You can add a .ruby-version file to your repository if you want to set it to a specific version of Ruby which rbenv will detect and switch to. That's pretty handy if you're working on an old app that needs a specific version of Ruby.

  1. Same as #2, the .ruby-version from the repository should do the trick for you, but possibly you will need to make sure you install the proper version of Ruby if you don't have it installed. Each version of Ruby lives entirely on its own, so you get entirely separate sets of gems between versions. You will notice, for example, that Bundler won't exist in your new installs of Ruby and will want to reinstall that.

  2. If you want to start fresh, all you'll have to do is install Ruby and bundler and then run bundle install in your app directories. That is really all there is to it.

Reply

Thanks for the answers Chris.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,387+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.