Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

By using a shim approach, like rbenv.

1. Maintain a directory of shim binaries with the same name as every Ruby binary (ruby, irb, rake, gem, etc).

2. Put the shim directory at the front of your $PATH.

3. When a shim is run (as in typing `rake` from the command line or running a script with a `#!/usr/bin/env ruby` shebang), check for a version file in the current directory or any parent directory, map that to the right path, and re-exec the corresponding binary.



Doesn't this solution not scale? Doesn't this mean a shim must be created for every gem that I install that has a binary? Or is this only required for "core" binaries?


`ls -l /usr/bin | wc -l` reports 1085 entries on my machine. Meanwhile, I have 40 entries in my ~/.rbenv/shims directory. I think the shell can handle it.


I'm sorry, I was not aware of the 'rehash' function, I thought rbenv would have to ship with all the required shims. The rehash functionality is quite clever and cool. Is there an easy way to have that automatically execute after I do any installation of a ruby or gem?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: