rbenv plugin now properly finds homebrew-installed rbenv (fixes #878) #888

Closed
wants to merge 4 commits into
from

Projects

None yet

5 participants

@dmarkow
dmarkow commented Jan 30, 2012

The current rbenv plugin looks in $HOME/.rbenv, /usr/local/rbenv, and /opt/rbenv for a bin directory. However, when rbenv is installed with homebrew, it gets installed directly in /usr/local/bin. Updated plugin looks for homebrew rbenv if the first search fails. This will fix #878.

maletor commented Feb 1, 2012

This is good stuff. +5million

Contributor

You're assuming that everyone installs Homebrew in /usr/local; so, it's broken.

maletor commented Feb 3, 2012

But so close.

dmarkow commented Feb 4, 2012

Just pushed a change to search the $PATH for the rbenv executable when the first check fails. This will cover the default homebrew /usr/local/bin location as well as any other directories the user may have stuck rbenv in.

Contributor

You probably want brew --prefix.

dmarkow commented Feb 4, 2012

Yeah, I decided to change it to search the whole path for any alternate installation of rbenv (homebrew or other). For example, the user could possibly install rbenv to ~/foo/rbenv and add it to their path; with searching the whole path, it would find this (and I didn't see any noticeable speed decrease on my end).

dmarkow commented Feb 4, 2012

Another maybe simpler option would be doing what the bundler plugin does and just doing a simple which rbenv check to see if the command exists, and setting the $FOUND_RBENV variable that way. Any thoughts on that?

maletor commented Feb 4, 2012

Thoughts are yes.

On Feb 3, 2012, at 7:59 PM, Dylan Markow
reply@reply.github.com
wrote:

Another maybe simpler option would be doing what the bundler plugin does and just doing a simple which rbenv check to see if the command exists, and setting the $FOUND_RBENV variable that way. Any thoughts on that?


Reply to this email directly or view it on GitHub:
#888 (comment)

@dmarkow dmarkow Simplify alternate search for rbenv executable.
Rather than iterating over the entire $PATH, just try `which rbenv`
similar to the Bundler plugin.
bf529e7
dmarkow commented Feb 9, 2012

Ok, it just tries which rbenv now if the first check fails.

Contributor

print $commands[rbenv]. The Zsh man page is your friend.

Contributor
if [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then
  path=("$HOME/.rbenv/bin" $path)
fi

if (( $+commands[rbenv] )); then
  eval "$(rbenv init - zsh)"
fi
Contributor
Peeja commented May 17, 2012

Why are we even doing the explicit path search in the first place? Shouldn't it be enough to take any rbenv that shows up in your path? Then the user gets to decide which rbenv to use by setting the PATH correctly in .zshrc, and this plugin gets a lot simpler.

Contributor

$HOME/.rbenv is not in $PATH.

Contributor
Peeja commented May 17, 2012

It should be. From the README:

  1. Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.

Or, if it's not, that's the user's choice not to use that installation of rbenv.

I think the alternate fix by @peeja (#1118) is better. Taking the first rbenv from $PATH is more reliable than explicit path searching.

dmarkow commented Jul 2, 2012

Closing my pull request in favor of @Peeja's #1118 -- his is much better. I agree it should be as simple as "if the rbenv command exists, then proceed."

@dmarkow dmarkow closed this Jul 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment