rbenv: Either documentation or installer fails to setup shims directory correctly
I have setup rbenv according to the documentation on a fresh CentOS 7.7 machine. The result is that the installation does not work (ruby is not found regardless of me adding it as local or global). I finally found out that the shims directory never makes it to the path and therefore executed
echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
which made the stuff work. I am unsure whether the installer or rbenv init should do this or the documentation is lacking this step.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (7 by maintainers)
Hello, I am just posting this here so that someone else can see it and maybe help me? It might also be something that other people are experiencing…
I appended
eval "$(rbenv init -)"into my ~/.zshrc and my shims are not being prepended to my $PATH.Here is what I get when I run
rbenv init -But when I run
which rubyI just get/usr/bin/ruby.Will it be necessary to add to my shell config something similar to the user who opened this thread,
export PATH="$HOME/.rbenv/shims:$PATH?I am wondering if I should go nuclear and uninstall / reinstall…
I was stuck in a similar situation on macOS 14.2 with M2, attempting to install rbenv. I would get no shims from
which rubybut saw the shims in my path. This comment was able to get me unstuck! Posting here for future hapless devs@jpeters-ml Have you followed these instructions and added the “eval” line to your zshrc?
After that and restarting your shell or terminal window, your PATH should be:
Hi mislav,
thanks for your explanations. I looked into it and I think I now got the problem (which is probably the cause for several issues I stumbled over while troubleshooting that have users complaining about
rbenv initnot working). I believe the documentation is misleading at best for users having no experience with rbenv and just want to use it.First, from your explanation and from the installation guide, I would assume that
rbenv initupdates the path such that ruby is working, i.e. it includes the shims directory.Second, I remember the output of
rbenv initthat you quoted and I still think this can only be interpreted as adding this line to~/.bash_profileis optional, i. e. if I do not want to load rbenv automatically, I do not need to do that, but I can callrbenv initon demand.However, calling
rbenv initon demand does not work, and I believe I have now understood why: If I add theevalline into my~/.bash_profile, the stuff is sourced in the shell, whereas if I just callrbenv init, it is not. The following ouput from a CentOS 7.7 machine illustrates this effect:I would therefore suggest hinting users at calling
eval "$(rbenv init -)"and notrbenv initif they want to use rbenv on demand and/or change the output ofrbenv inittelling users that they must add theevalline.Best regards, Christoph