Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eval "$(rbenv init -)" every time I start on Mac OS X 10.11 El Capitan #815

Closed
ghost opened this issue Oct 29, 2015 · 20 comments
Closed

eval "$(rbenv init -)" every time I start on Mac OS X 10.11 El Capitan #815

ghost opened this issue Oct 29, 2015 · 20 comments

Comments

@ghost
Copy link

ghost commented Oct 29, 2015

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
@mislav
Copy link
Member

mislav commented Oct 30, 2015

If you followed the guide in the Readme, how does your ~/.bash_profile look like? Does it have any rbenv initialization files in it

@ghost
Copy link
Author

ghost commented Oct 30, 2015

@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?

@mislav
Copy link
Member

mislav commented Oct 30, 2015

What exactly doesn't work?

Can you paste us the output of:

grep rbenv ~/.bash_profile`

@ghost
Copy link
Author

ghost commented Oct 31, 2015

grep: /Users/myusername/.bash_profile: No such file or directory

@mislav
Copy link
Member

mislav commented Nov 2, 2015

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.

@egg-develops
Copy link

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

@egg-develops
Copy link

I also appended to: .zshrc

@mislav
Copy link
Member

mislav commented Dec 14, 2015

@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

@mislav
Copy link
Member

mislav commented Dec 14, 2015

Closing since this thread is about configuration issue on users' side and not a bug with rbenv.

@mislav mislav closed this as completed Dec 14, 2015
@barronlroth
Copy link

@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 -)"

@mislav
Copy link
Member

mislav commented Sep 14, 2016

@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

@barronlroth
Copy link

@mislav That's the fix! Thank you brother.

@paulbhartzog
Copy link

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 init for instructions as stated in the caveats. You'll only ever have to do this once.

  1. There are no caveats that I could find.
  2. If I only have to do rbenv init once 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

@mislav
Copy link
Member

mislav commented Oct 10, 2016

  1. There are no caveats that I could find.

Homebrew prints the "Caveats" section when you install its rbenv formula.

  1. 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.

@paulbhartzog
Copy link

paulbhartzog commented Oct 10, 2016

@mislav

  1. There are no caveats that I could find.
    Homebrew prints the "Caveats" section when you install its rbenv formula.

ah, much thx

  1. 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. :-)

@muescha
Copy link

muescha commented Feb 23, 2017

caveats are removed from forumla with Homebrew/homebrew-core@ea9dd0e

@rahulsharma20
Copy link

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

@brsastre
Copy link

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.

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.

@ehsong
Copy link

ehsong commented Jul 21, 2019

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.

@SherryWu178
Copy link

I found this video quite useful!
https://www.youtube.com/watch?v=-DJz7yC3iOI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants