Rbenv: missing ~/.rbenv/shims in PATH

Created on 1 Mar 2016  ·  14Comments  ·  Source: rbenv/rbenv

I followed the instructions and here is the output.

vagrant@vagrant-ubuntu-trusty-64:~$ rbenv install 2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
Installing ruby-2.3.0...
Installed ruby-2.3.0 to /home/vagrant/.rbenv/versions/2.3.0

vagrant@vagrant-ubuntu-trusty-64:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
vagrant@vagrant-ubuntu-trusty-64:~$ rbenv local 2.3.0
vagrant@vagrant-ubuntu-trusty-64:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
vagrant@vagrant-ubuntu-trusty-64:~$ rbenv which ruby
/home/vagrant/.rbenv/versions/2.3.0/bin/ruby
vagrant@vagrant-ubuntu-trusty-64:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

as you could see, the ruby is not 2.3.0 but 1.9.3[system]

eventually, I notice my .bashrc

export PATH="$HOME/.rbenv/bin:$PATH"

and according to the README, the path should contain '~/.rbenv/shims'. Therefore, I add it to the PATH in .bashrc

export PATH="$HOME/.rbenv/bin:~/.rbenv/shims:$PATH"

and rbenv is working again.

Therefore, I suggest to revise Installation/Step2 to export the path as above. Thank you.

Most helpful comment

Hi
Did that and i still get: "Checking for rbenv shims in PATH: not found"

All 14 comments

Better yet. I found this instruction from the old README

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

The new README has this line:

  1. Run ~/.rbenv/bin/rbenv init for shell-specific instructions on how to initialize rbenv to enable shims and autocompletion.

When you run the command, it gives you the instructions to add that eval line to your ~/.bashrc.

Hi
Did that and i still get: "Checking for rbenv shims in PATH: not found"

@mislav Please, provide some solution, because it seems the README and the its instructions are not straightforward for many of us.
So I ran the init command below, but what this message exactly want to tell:

 ~/.rbenv/bin/rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

Yes, it appended a line in the ~/.bash_profile, but the message after inspection remained unchanged:

~/.rbenv/plugins$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /home/vagrant/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: not found
  The directory `/home/vagrant/.rbenv/shims' must be present in PATH for rbenv to work.
  Please run `rbenv init' and follow the instructions.

Checking `rbenv install' support: /home/vagrant/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20190130-2-g843c8bf)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
vagrant@vagrant:~/.rbenv/plugins$ rbenv rehash
vagrant@vagrant:~/.rbenv/plugins$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /home/vagrant/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: not found
  The directory `/home/vagrant/.rbenv/shims' must be present in PATH for rbenv to work.
  Please run `rbenv init' and follow the instructions.

Checking `rbenv install' support: /home/vagrant/.rbenv/plugins/ruby-build/bin/rbenv-install (ruby-build 20190130-2-g843c8bf)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK

Thank you!

@george-gssy You might need to add the instructions to .bashrc instead of .bash_profile and restart your shell afterwards. See https://github.com/rbenv/rbenv/issues/1130

This problem STILL PERSIST. Following the instructions results in an incomplete installation.

You know what...F-it. I've just spent 4 hours runing this mari-go-round...I'll look up chruby or maybe I'll go back to RVM. perhaps those will be more competent solutions.

@thefonso Hey

When in doubt, read the source code!
https://github.com/rbenv/rbenv/blob/master/libexec/rbenv-init
The shims directory is created and added to PATH by eval "$(rbenv init -)". The problem is that you are just writing the script to ~/.bashrc without executing it (it would be executed next time you log in). 🤷‍♂

For example, this is how you can load the file ~/.bashrc and execute its contents:

source ~/.bashrc

Read the instructions: https://github.com/rbenv/rbenv#basic-github-checkout

My code looks like this:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc

# Load and execute the script that was just written in ~/.bashrc file
source ~/.bashrc

# Install!
rbenv install 2.3.0

And you must know what file to write in! My script is run on Ubuntu and bash, so the ~/.bashrc file is being used.

By the way, instructions says that you must call rbenv init first and it will tell you what (depending on your system/shell) to write in the second line, but I found a way how can I know what init command to write in the ~/.bashrc file without running rbenv init first:

# instead of
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
# you can run
echo "$(~/.rbenv/bin/rbenv init |& grep eval)" >> ~/.bashrc
# which extracts the output of `rbenv init` and the result is the same

#StayHome

I know this issue is closed, but I just installed rbenv today, cloned from git today, on a computer running Ubuntu 18.04.4 LTS and had the same issue.
I ran the rbenv doctor and it said:

$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /home/raw/.rbenv/bin/rbenv
Checking for rbenv shims in PATH: not found
  The directory `/home/raw/.rbenv/shims' must be present in PATH for rbenv to work.
  Please run `rbenv init' and follow the instructions.

So I ran rbenv init:

$ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init -)"

This had no effect, so after playing around for a bit I figured out ~/.bash_profile was never run when opening a new tab, so I added it to ~/.bashrc instead, which worked perfectly.
This may be an Ubuntu specific thing, so I suggest updating the script to correctly instruct the user to do so on Ubuntu systems.

Also, I'm wondering, is there any reason why one couldn't instruct the users to simply add it to the path together with ~/.rbenv/bin earlier in the installation instructions?

I use Debian 10 servers on clouds like Scaleway and Hetzner, and there are .bashrc and .profile files.

I see in the README:

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

But if I create .bash_profile file — .profile is not loading. And terminal prompt becomes non-colored.

So, I'm adding this line to ~/.profile, where other default PATH changes (without export, I don't know for what is it).

Also in the output of rbenv init I see:

# Load rbenv automatically by appending
# the following to ~/.bashrc:

eval "$(rbenv init -)"

Yes, I have .bashrc file, but it is not loading. Its first line contains:

# ~/.bashrc: executed by bash(1) for non-login shells. 

So… these instructions don't work. And I should add this eval "$(rbenv init -)" to ~/.profile too.

@AlexWayfer Do I understand your problem correctly? Are you trying to run something without logging in as the user? Maybe this is the solution:

Look at the ~/.bashrc and check if there are these lines on the top of that file:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

If so, that might be the reason why the script after these lines are not being executed, so just comment them out or delete them. Or move the lines you want to be executed no matter what above these lines.

I have had this problem on Ubuntu because I was running commands as different user "myapp" (who has "rbenv" set up) and I'm pretty sure this is the case for you too. 😉

Are you trying to run something without logging in as the user?

I'm logged in via ssh.

so just comment them out or delete them

Why is it default? I don't like to disable/remove something without understanding why it was done so.

I have had this problem on Ubuntu because I was running commands as different user "myapp" (who has "rbenv" set up) and I'm pretty sure this is the case for you too.

I didn't understand, sorry. I have Linux user myapp and logging in to it via ssh and trying to setup rbenv.

I also have this:

➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash Checking forrbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: not found
The directory /Users/itz/.rbenv/shims' must be present in PATH for rbenv to work. Please runrbenv init' and follow the instructions.

Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20200727)
Counting installed Ruby versions: 2 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
➜ ~

so I ran:

then I run ➜  ~ rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

What did work if you have the ~/.zshrc: ?

What can I do?

I also have this:

➜ ~ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash Checking forrbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: not found
The directory /Users/itz/.rbenv/shims' must be present in PATH for rbenv to work. Please runrbenv init' and follow the instructions.

Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20200727)
Counting installed Ruby versions: 2 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
➜ ~

so I ran:

then I run ➜  ~ rbenv init
# Load rbenv automatically by appending
# the following to ~/.zshrc:

eval "$(rbenv init -)"

What did work if you have the ~/.zshrc: ?

What can I do?

  1. open ~/.zshrc file
  2. copy eval "$(rbenv init -)" to this file after last line
  3. save
  4. in terminal, carry out source ~/.zshrc
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mhinz picture mhinz  ·  3Comments

sgnd picture sgnd  ·  3Comments

aaalveee picture aaalveee  ·  4Comments

kaikuchn picture kaikuchn  ·  5Comments

vennsoh picture vennsoh  ·  4Comments