From the rbenv README:

Understanding PATH

When you run a command like ruby or rake, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:

/usr/local/bin:/usr/bin:/bin

Directories in PATH are searched from left to right, so a matching executable in a directory at the beginning of the list takes precedence over another one at the end. In this example, the /usr/local/bin directory will be searched first, then /usr/bin, then /bin.

Understanding Shims

rbenv works by inserting a directory of shims at the front of your PATH:

~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin

Check where you have added ~/.rbenv/shims to the PATH (probably in a file like ~/.bashrc, or ~/.zshrc?), and ensure you are adding it to the START of the PATH, not the end.

To see the full contents of the $PATH variable, you can run:

echo $PATH
Answer from Tom Lord on Stack Overflow
🌐
GitHub
github.com › rbenv › rbenv › issues › 1217
Trying to install rbenv but running into this problem: "Checking for rbenv shims in PATH: not found" · Issue #1217 · rbenv/rbenv
January 31, 2020 - Checking for `rbenv' in PATH: /home/[my name]/.rbenv/bin/rbenv Checking for rbenv shims in PATH: not found The directory `/home/[my name]/.rbenv/shims' must be present in PATH for rbenv to work. Please run `rbenv init' and follow the instructions.
Author   jaedashson
Top answer
1 of 6
4

From the rbenv README:

Understanding PATH

When you run a command like ruby or rake, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:

/usr/local/bin:/usr/bin:/bin

Directories in PATH are searched from left to right, so a matching executable in a directory at the beginning of the list takes precedence over another one at the end. In this example, the /usr/local/bin directory will be searched first, then /usr/bin, then /bin.

Understanding Shims

rbenv works by inserting a directory of shims at the front of your PATH:

~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin

Check where you have added ~/.rbenv/shims to the PATH (probably in a file like ~/.bashrc, or ~/.zshrc?), and ensure you are adding it to the START of the PATH, not the end.

To see the full contents of the $PATH variable, you can run:

echo $PATH
2 of 6
2

Simplified instructions for MacOS users:

sudo vim ~/.zshrc

Add this at the end of file:

eval "$(rbenv init - zsh)"

Write and Quit vim editor

:wq

Verify setup:

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash

Expected output:

Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20220910.1)
Counting installed Ruby versions: none
There aren't any Ruby versions installed under `/Users/username/.rbenv/versions'.
You can install Ruby versions like so: rbenv install 3.1.2
Checking RubyGems settings: OK
Auditing installed plugins: OK
Discussions

Checking for rbenv shims in PATH: found at wrong position
I try to check my rbenv problem with using its rbenv-doctor command ; curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash I get this; Checking for `rbenv' in PA... More on github.com
🌐 github.com
1
May 26, 2021
Troubles with rbenv, manjaro, and shims in PATH - Help - The Odin Project
[seitan@veggies ~]$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash Checking for rbenv' in PATH: /home/seitan/.rbenv/bin/rbenv Checking for rbenv shims in PATH: not found The directory/home/seitan/.rbenv/shims’ must be present in PATH for rbenv to work. More on forum.theodinproject.com
🌐 forum.theodinproject.com
13
0
September 29, 2018
rbenv, what am I doing in wrong in here?

'which rails' could give some enlightment. Maybe it's an alias on your configuration? or maybe it is installed as a system gem, and you need to install rails once again for 3.0.6

also, try 'bundle exec rails server' instead

More on reddit.com
🌐 r/rails
11
4
December 1, 2023
ruby - Rbenv not rehashing correctly and making shims - Stack Overflow
The bottom line is, rbenv isn't making shims. I've exhausted ideas of what could be the problem. After a few days of banging my head against a wall to fix but no avail, I think it's time to ask for... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › rbenv › rbenv › issues › 877
missing ~/.rbenv/shims in PATH · Issue #877 · rbenv/rbenv
March 1, 2016 - export PATH="$HOME/.rbenv/bin:~/.rbenv/shims:$PATH"
Author   lkfken
🌐
GitHub
github.com › rbenv › rbenv › issues › 1336
Checking for rbenv shims in PATH: found at wrong position · Issue #1336 · rbenv/rbenv
May 26, 2021 - Checking for `rbenv' in PATH: /usr/local/bin/rbenv Checking for rbenv shims in PATH: found at wrong position 👈 The directory `/Users/myname/.rbenv/shims' is present in PATH, but is listed too late. The Ruby version found in `/usr/local/opt/ruby/bin' will have precedence.
Published   May 26, 2021
🌐
The Odin Project
forum.theodinproject.com › help
Troubles with rbenv, manjaro, and shims in PATH - Help - The Odin Project
September 29, 2018 - [seitan@veggies ~]$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash Checking for rbenv' in PATH: /home/seitan/.rbenv/bin/rbenv Checking for rbenv shims in PATH: not found The directory/home/seitan/.rbenv/shims’ must be present in PATH for rbenv to work.
🌐
GitHub
github.com › rbenv › rbenv › issues › 1067
Ubuntu install problem · Issue #1067 · rbenv/rbenv
# curl -fsSL https://github.co...nv/bin/rbenv Checking for rbenv shims in PATH: not found The directory `/root/.rbenv/shims' must be present in PATH for rbenv to work....
Top answer
1 of 1
3

I suspect your .bashrc is the problem. It shouldn't contain:

# If I don't set this, gem reverts back to nonexistent RVM directory.
export GEM_HOME=$(ruby -e 'print Gem.user_dir')
export GEM_PATH=$(ruby -e 'print Gem.user_dir')

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"

Of my ~/.bashrc, ~/.profile and ~/.bash_profile files, only the last has configuration for rbenv:

# echo Using rbenv...
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

That was created when I installed rbenv, which matches the settings for my other systems where I use rbenv, including some that previously had RVM installed.

Your double PATH assignments look like the culprit. Compare the PATH for my system to yours, which is listed by gem env:

 - /Users/ttm/.rbenv/versions/2.2.3/bin
 - /Users/ttm/.rbenv/libexec
 - /Users/ttm/.rbenv/plugins/ruby-build/bin
 - /Users/ttm/.rbenv/plugins/rbenv-whatis/bin
 - /Users/ttm/.rbenv/plugins/rbenv-vars/bin
 - /Users/ttm/.rbenv/plugins/rbenv-use/bin
 - /Users/ttm/.rbenv/plugins/rbenv-update/bin
 - /Users/ttm/.rbenv/plugins/rbenv-update-rubies/bin
 - /Users/ttm/.rbenv/plugins/rbenv-gemset/bin
 - /Users/ttm/.rbenv/plugins/rbenv-env/bin
 - /Users/ttm/.rbenv/plugins/rbenv-each/bin
 - /Users/ttm/.rbenv/shims
 - /Users/ttm/.rbenv/bin

Similarly, my which pry returns:

/Users/ttm/.rbenv/shims/pry

Using rbenv's env plugin shows:

RBENV_VERSION=2.2.3
RBENV_GEMSET_ALREADY=yes
RBENV_ROOT=/Users/ttm/.rbenv
RBENV_HOOK_PATH=:/Users/ttm/.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/usr/lib/rbenv/hooks:/Users/ttm/.rbenv/plugins/rbenv-default-gems/etc/rbenv.d:/Users/ttm/.rbenv/plugins/rbenv-gemset/etc/rbenv.d:/Users/ttm/.rbenv/plugins/rbenv-readline/etc/rbenv.d:/Users/ttm/.rbenv/plugins/rbenv-vars/etc/rbenv.d
PATH=/Users/ttm/.rbenv/versions/2.2.3/bin:/Users/ttm/.rbenv/libexec:/Users/ttm/.rbenv/plugins/ruby-build/bin:/Users/ttm/.rbenv/plugins/rbenv-whatis/bin:/Users/ttm/.rbenv/plugins/rbenv-vars/bin:/Users/ttm/.rbenv/plugins/rbenv-use/bin:/Users/ttm/.rbenv/plugins/rbenv-update/bin:/Users/ttm/.rbenv/plugins/rbenv-update-rubies/bin:/Users/ttm/.rbenv/plugins/rbenv-gemset/bin:/Users/ttm/.rbenv/plugins/rbenv-env/bin:/Users/ttm/.rbenv/plugins/rbenv-each/bin:/Users/ttm/.rbenv/shims:/Users/ttm/.rbenv/bin:/Users/ttm/.pyenv/shims:/Users/ttm/.pyenv/bin:/Users/ttm/perl5/perlbrew/bin:/Users/ttm/perl5/perlbrew/perls/perl-5.18.1/bin:/Users/ttm/bin:/usr/local/mysql-5.6.16-osx10.7-x86_64/bin:/Users/ttm/libsmi/bin:/usr/local/git/bin:/usr/local/bin:/Library/PostgreSQL/9.2/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin
RBENV_SHELL=bash
RBENV_DIR=/Users/ttm
RUBYLIB=/Users/ttm/.rbenv/rbenv.d/exec/gem-rehash:

I'd do these steps:

  1. Modify ~/.bashrc, and the others, removing any lines referring to rbenv and/or RVM. RVM uses all three init files, plus .zshrc, whereas rbenv only seems to touch ~/.bash_profile.
  2. Close the terminal session. Reopen it.
  3. Confirm the PATH is free from all references to RVM and rbenv.
  4. Reinstall rbenv following the Installation instructions. It won't override the current installation, but instead will reinstall its changes to ~/.bash_profile.
  5. Close the terminal session again and reopen it.

rbenv should now be initialized correctly.

Find elsewhere
🌐
GitHub
raw.githubusercontent.com › rbenv › rbenv-installer › main › bin › rbenv-doctor
https://raw.githubusercontent.com/rbenv/rbenv-inst...
Please reorder your PATH." } | indent echo : $((warnings++)) else printc green "OK" echo fi else printc red "not found" echo { echo "The directory \`$shims_dir' must be present in PATH for rbenv to work." echo "Please run \`rbenv init' and follow the instructions."
🌐
Medium
medium.com › @Sudhagar › rbenv-how-it-works-e5a0e4fa6e76
Rbenv — How it works
July 23, 2016 - After you install a gem, its shim won’t be there. Hence the need to run rbenv rehash every-time after you install a gem. Here is step by step breakdown on how shims are created.
🌐
GitHub
github.com › onmyway133 › notes › issues › 365
rbenv Checking for rbenv shims in PATH · Issue #365 · onmyway133/notes
September 11, 2018 - https://stackoverflow.com/questions/10940736/rbenv-not-changing-ruby-version/42002830 export PATH="$HOME/.rbenv/shims:$PATH"
Author   onmyway133
🌐
GitHub
github.com › rbenv › rbenv › issues › 1310
Multiple paths · Issue #1310 · rbenv/rbenv
February 26, 2021 - Checking for rbenv shims in PATH: not found The directory /home/martin/.rbenv/shims' must be present in PATH for rbenv to work.
Published   Feb 26, 2021
🌐
GitHub
github.com › rbenv › rbenv › issues › 1193
Either documentation or installer fails to setup shims directory correctly · Issue #1193 · rbenv/rbenv
October 13, 2019 - 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
Author   crowbar27
🌐
GitHub
github.com › rbenv › rbenv › issues › 971
Lots of .rbenv/shims in path... · Issue #971 · rbenv/rbenv
February 21, 2017 - My path looks a bit like this: /Users/ian/.rbenv/shims:/Users/ian/.rbenv/shims:/Users/ian/.rbenv/shims:/Users/ian/.rbenv/shims:/Users/ian/.rbenv/shims:/Users/ian/.rbenv/shims:/Users/ian/.rbenv/shim...
Author   pookah-net
🌐
GitHub
github.com › rbenv › rbenv › issues › 755
Shims path not added to $PATH on fish on Ubuntu 14.04 · Issue #755 · rbenv/rbenv
July 16, 2015 - Hi, I used rbenv for more than 2 years now so : Thank you :) Recently I try the shell "fish" When I go in a project which has a .ruby-version defined, it didn't change : when I type ruby --version it is not the same as cat .ruby-version ...
🌐
Javierjulio
javierjulio.com › rbenv
rbenv - Simple Ruby Version Management - Javier Julio
Because of the simplicity of the shim approach, all you need to use rbenv is ~/.rbenv/shims in your $PATH. Compatibility note: rbenv is incompatible with rvm. Things will appear to work until you try to install a gem. The problem is that rvm actually overrides the gem command with a shell function! Please remove any references to rvm before using rbenv. This will get you going with the latest version of rbenv and make it easy to fork and contribute any changes back upstream. Check out rbenv into ~/.rbenv.
🌐
GitHub
github.com › rbenv › rbenv › issues › 1467
Empty shims directory. rbenv rehash fails silently · Issue #1467 · rbenv/rbenv
December 14, 2022 - '[' '' = --help ']' +(/opt/homebrew/bin/rbenv:127): exec /opt/homebrew/Cellar/rbenv/1.2.0/libexec/rbenv-rehash +(/opt/homebrew/Cellar/rbenv/1.2.0/libexec/rbenv-rehash:7): SHIM_PATH=/Users/lynn/.rbenv/shims +(/opt/homebrew/Cellar/rbenv/1.2.0/libexec/rbenv-rehash:8): PROTOTYPE_SHIM_PATH=/Users/lynn/.rbenv/shims/.rbenv-shim +(/opt/homebrew/Cellar/rbenv/1.2.0/libexec/rbenv-rehash:11): mkdir -p /Users/lynn/.rbenv/shims +(/opt/homebrew/Cellar/rbenv/1.2.0/libexec/rbenv-rehash:17): set -o noclobber +(/opt/homebrew/Cellar/rbenv/1.2.0/libexec/rbenv-rehash:27): set +o noclobber +(/opt/homebrew/Cellar/rbe
Author   lynndylanhurley