Why, after followin your guide in the Readme, on Mac OSX 10.11 El Capitan I have to initialize every time Rbenv with this command?
eval "$(rbenv init -)"
After reboot my Mac have the standard ruby -v and my $PATH is the standard PATH:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
If you followed the guide in the Readme, how does your ~/.bash_profile look like? Does it have any rbenv initialization files in it
@mislav, i followed this part of the guide:
Homebrew on Mac OS X
As an alternative to installation via GitHub checkout, you can install rbenv and ruby-build using the Homebrew package manager on Mac OS X:
$ brew update
$ brew install rbenv ruby-build
Afterwards you'll still need to add eval "$(rbenv init -)" to your profile as stated in the caveats. You'll only ever have to do this once.
Why it doesn't work?
What exactly doesn't work?
Can you paste us the output of:
grep rbenv ~/.bash_profile`
grep: /Users/myusername/.bash_profile: No such file or directory
So one of the installation steps included running this:
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
This will create a ~/.bash_profile file and add a line to it that initializes rbenv every time you start a new Terminal tab. Let me know if that works.
Hello @mislav
My output from grep shows my multiple attempts to append:
grep rbenv ~/.bash_profile`
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
eval "$(rbenv init -)"
eval "$(rbenv init -)"`
But I still have the:
#Load rbenv automatically by appending
#the following to your profile:
eval "$(rbenv init -)"
every time I open my iTerm.
Can you guide me in anyway?
Thank you
I also appended to: .zshrc
@egdevelops If you're using zsh as your login shell (default shell when you open iTerm), then changing .bash_profile has no effect and you can clean it up. Also there's no reason why .bash_profile should have so many duplicate lines to set up rbenv.
For zsh, ensure that your ~/.zshrc has this:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Then restart your shell. You should be able to run rbenv commands such as:
$ rbenv version
2.2.3 (set by /Users/mislav/.rbenv/version)
$ rbenv shell
rbenv: no shell-specific version configured
Closing since this thread is about configuration issue on users' side and not a bug with rbenv.
@egg-develops Did you ever find a solution? My terminal has the same output every time it opens:
# Load rbenv automatically by appending
# the following to ~/.bash_profile:
eval "$(rbenv init -)"
My .bash_profile:
rbenv init
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export PATH="/usr/local/bin:$PATH"
export CLICOLOR=1
export NVM_DIR="/Users/barron/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
eval "$(rbenv init -)"
@barronlroth You have 3 lines in your bash profile that call rbenv init, but you only need 1.
You can keep this line, but remove other invocations:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
@mislav That's the fix! Thank you brother.
Is it still necessary or desirable to have this in .bash_profile?
eval "$(rbenv init -)"
The Homebrew section of the docs at https://github.com/rbenv/rbenv
says:
Afterwards you'll still need to run
rbenv initfor instructions as stated in the caveats. You'll only ever have to do this once.
- There are no caveats that I could find.
- If I only have to do
rbenv initonce then why would I want it in my .bash_profile?
Running rbenv init manually gets you this:
Load rbenv automatically by appending
the following to ~/.bash_profile:
eval "$(rbenv init -)"
but it doesn't say _why_ you might want to load rbenv automatically, or what will happen if you do not put that in your .bash_profile.
I'd like to remove it if it is not necessary or desirable.
For example, is there a test to see if it is or is not performing a useful function?
much thx
- There are no caveats that I could find.
Homebrew prints the "Caveats" section when you install its rbenv formula.
- If I only have to do
rbenv initonce then why would I want it in my .bash_profile?
It means that you only have to run it once _manually_ to receive instructions to configure your .bash_profile. The benefits of having eval ... rbenv init line in your shell initialization file are outlined in the README. The only hard requirement for rbenv functioning is to prepend ~/.rbenv/shims to your PATH. If you don't want to use rbenv init, and you're fine with missing out on other optional features, you can do this manually by editing PATH in your, again, .bash_profile.
@mislav
- There are no caveats that I could find.
Homebrew prints the "Caveats" section when you install its rbenv formula.
ah, much thx
- If I only have to do rbenv init once then why would I want it in my .bash_profile?
It means that you only have to run it once manually to receive instructions to configure your .bash_profile. The benefits of having eval ... rbenv init line in your shell initialization file are outlined in the README. The only hard requirement for rbenv functioning is to prepend ~/.rbenv/shims to your PATH. If you don't want to use rbenv init, and you're fine with missing out on other optional features, you can do this manually by editing PATH in your, again, .bash_profile.
Great! Thx for the pointer. Not having to do rbenv rehash manually is worth it alone. :-)
caveats are removed from forumla with https://github.com/Homebrew/homebrew-core/commit/ea9dd0e0dd9abf2d452e5675ffad5169e617a041
I have the same problem.
I installed rbenv with homebrew but when I do rbenv init, I get the same error.
Here's the output of grep rbenv ~/.bash_profile:
eval "$(rbenv init -)"
and output from rbenv init - is:
export PATH="/Users/rahulsharma/.rbenv/shims:${PATH}"
export RBENV_SHELL=bash
source '/usr/local/Cellar/rbenv/1.1.0/libexec/../completions/rbenv.bash'
command rbenv rehash 2>/dev/null
rbenv() {
local command
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi
case "$command" in
rehash|shell)
eval "$(rbenv "sh-$command" "$@")";;
*)
command rbenv "$command" "$@";;
esac
}
Thanks in advance
So one of the installation steps included running this:
echo 'eval "$(rbenv init -)"' >> ~/.bash_profileThis will create a
~/.bash_profilefile and add a line to it that initializes rbenv every time you start a new Terminal tab. Let me know if that works.
This fuck*ng worked for me. Sorry about the bad language, but it is appropriate since I have been struggling with this for a few hours.
What should I do if echo 'eval "$(rbenv init -)"' >> ~/.bash_profile doesn't work? I keep getting the message
# Load rbenv automatically by appending
# the following to ~/.bash_profile:
eval "$(rbenv init -)"
I did check the bash profile and the eval "$(rbenv init -)"was appended to it.
I found this video quite useful!
https://www.youtube.com/watch?v=-DJz7yC3iOI
Most helpful comment
So one of the installation steps included running this:
This will create a
~/.bash_profilefile and add a line to it that initializes rbenv every time you start a new Terminal tab. Let me know if that works.