Couple weeks ago I switched from RVM to rbenv because I think it’s a cleaner and faster way to handle Ruby versions. It is more respecful of the Unix philosophy.
It worked like a charm right after the installation but Pow wasn’t working anymore. There’s just a little trick to know.
So let’s have a reminder about rbenv and see how to make it work with Pow.
Daily use
I’m running Mac OS X and chose to use HomeBrew as my package manager. Let’s install rbenv and Pow.
Rbenv Install
You’re now ready to install your rubies. Be sure to uninstall RVM first if you installed it. RVM overwrites many shell commands and would cause troubles to rbenv if there are both installed:
Add this line to your .bash_profile or .zshenv :
Open up a new shell and you’re ready to go.
Rubies install
First you can list candidates for installation:
Install the one you need:
Check installed versions:
Specify a default Ruby version to use system-wide:
Specify an other version to use in a given directory / project:
You can also set a ruby version to use in a shell for its lifetime:
Gemsets
rbenv users tends to think that Bundler is the way to go to handle project dependencies. Why use a gemset when the project itself can be the gemset. If you have a Gemfile then you can do:
Gems will be installed in vendor/bundle project directory. Be sure to exclude this dir from your SCM.
You can automate this behaviour by using Bundler config file. Edit ~/.bundle/config like so:
If you really need and want something similar to RVM gemsets, take a look at rbenv-gemset.
Using Pow with rbenv
Update: Note for users of Pow < 0.4.2 only. As of Pow >= 0.4.2 the following problem doesn’t exist anymore since Pow now loads user’s environment variables properly for Zsh users.
I ran into a problem when I tried to access my projects using Pow. Pow was getting the request but crashes due to gems missing or bad ruby version.
Pow doesn’t know anything about rbenv so you need to tell him about the right PATH to be able to use rbenv.
Edit ~/.powconfig like this:
Be sure to restart pow after editing this file.
Now you have rbenv and Pow up & running!
Share on
Twitter Facebook LinkedInHave comments or want to discuss this topic?
Send an email to ~bounga/public-inbox@lists.sr.ht