Rbenv: bash: rbenv: command not found

Created on 22 Dec 2014  路  21Comments  路  Source: rbenv/rbenv

I'm currently running Debian Wheezy. I followed the instructions for the standard rbenv installation on http://octopress.org/docs/setup/rbenv/
Since I'm running Debian, I changed the commands to add rbenv to my .bashrc instead of .bash_profile:

git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build '

I then ran
source ~/.bashrc
and got the following error:
bash: rbenv: command not found

Any ideas about what I'm doing wrong?

unconfirmed

Most helpful comment

@eshacker
make sure your shell is restarted.
instead of
exec $SHELL
try this:
exec -l $SHELL
it' works for me.

if it doesn't cut it, go ahead and reinstall ruby.
and continue this chapter

All 21 comments

The steps that you've described all seem good. I suspect that the error "rbenv: command not found" is coming from the eval line, which would happen if ~/.rbenv/bin wasn't on the PATH, but the previous line sets up the PATH correctly so I'm really not sure what's going on wrong.

Can you tell me the output of grep rbenv ~/.bashrc and ls -l ~/.rbenv/bin?

Hi mislav, here is the output of both commands:

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

and

$ ls -l ~/.rbenv/bin
ls: cannot access /home/zevski/.rbenv/bin: No such file or directory

So clearly ~/.rbenv/bin isn't on the PATH because it doesn't exist, not sure why.

The last bit looks like you never cloned rbenv into this location, which is confusing because you said you ran git clone git://github.com/sstephenson/rbenv.git .rbenv. Can you verify that the cloning of the project went alright, or inspect the ~/.rbenv directory to check what went wrong with the checkout?

It's pretty hard for me to figure out what's going on on your system because something's obviously not set up well, but it should be pretty easy for you to figure it out by just retracing the installation steps.

I inspected the ~/.rbenv directory and discovered that the only thin in it was the plugins directory, so I erased ~/.rbenv and cloned it again. This solved the issue. Thanks for your help!

mislav I'm having the same problem bash rbenv command not found but when i run the command # grep rbenv ~/.bashrc i get the following output

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

and when i run the command # ls -l ~/.rbenv/bin
i get the following output

total 4
lrwxrwxrwx 1 root root 16 Oct 18:33 rbenv -> ../libexec/rbenv
-rwxr-xr-r-x 1 root root 724 Oct 16 18:33 ruby-local-exec

what problem could i be facing

still when i run the # apt-get remove rbenv i get the following message

reading package lists....... done
package 'rbenv' is not installed, so not remove
0 upgrade, 0 newly installed, 0 to remove and 444 not upgraded.

and i try to re- clone it from github

cd ~
# git clone git://github.com/sstephenson/rbenv.git .rbenv i get the following error message
fatal: destination path ' .rbenv' alredy exists and is not an empty directory

Hi @magoo23. One thing that stands out to me from what you shared is that you might have been logged in as the wrong user. It seems that you might have been logged in as root before? Can you ensure you're logged in as ordinary user, and that rbenv is cloned into ~/.rbenv and owned by your user (not root) and that ~/.bashrc is like you shown us above. It might help!

Hi mislav thanks for the reply, do i need to create a new username, this is because i'm logging in as root like you have stated
rgds mago..

Ah, I see. You are always logging in as root and you don't use a regular (non-root) user on that system, right? Then disregard my comment. But I do not know why you get an error.

When you get "bash: rbenv: command not found", check your echo $PATH to see whether the directory that contains the rbenv executable is on the PATH. That's where I would start at. Sorry that I can't be of more help.

@mislav
i have same problem
im using kali linux. when i type this :
type rbenv
i get this output :
bash: rbenv: command not found
and:
grep rbenv ~/.bashrc and ls -l ~/.rbenv/bin
i get:
/root/.bashrc grep: and: No such file or directory grep: ls: No such file or directory grep: /root/.rbenv/bin: No such file or directory
can u help me?

@benyaminpy No I can't help you much. You need to install rbenv to a specific directory (such as ~/.rbenv) and add its bin directory to your PATH. It shouldn't be too hard to do. From the output you shared, I can't determine how far along this process did you get since I didn't get most of what you were saying. But I also can't hand-hold you through the process.

Please refer to rbenv-installer as a way of automating most of the installation of rbenv. Then, you can use rbenv-doctor to check whether it was successful.

I had same problem after following https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-centos-7 :

On centos 7

sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
exec $SHELL

But this put things in ~/.bash_profile, didn't work. I put relevant path exports to ~/.bashrc and it worked.

I also installed rbenv-doctor: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash to check the state of things. Then, just rbenv install -v 2.3.0

@eshacker
make sure your shell is restarted.
instead of
exec $SHELL
try this:
exec -l $SHELL
it' works for me.

if it doesn't cut it, go ahead and reinstall ruby.
and continue this chapter

the suggestion @eshacker gave worked for me as well (ran in to the same issues with bash_profile)

another +1 for @eshacker. this is the code to use for centos 7:

git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL

git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL

@eshacker Dude Thanks a lot you saved me!!

Hi guys, RHEL 7.2 had the same problem but after putting the configs in the bash_profile, it worked.

In your Terminal --> Edit Profile Preferences --> then flag under Title and Command --> Run command as a login shell. Close the terminal and reopen a new one.

Hi magoo23 you should install ruby_build plugins and you can refer to https://github.com/rbenv/ruby-build#readme

Hi Magoo23, do you have zsh installed? i had the same issue it was because of zsh

That was me.
I was writing to .bashrc instead of .zshrc facepalm

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ponamute picture ponamute  路  4Comments

wakproductions picture wakproductions  路  4Comments

slayer picture slayer  路  4Comments

bradrydzewski picture bradrydzewski  路  4Comments

kaikuchn picture kaikuchn  路  5Comments