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

bash: rbenv: command not found #670

Closed
zevski opened this issue Dec 21, 2014 · 22 comments
Closed

bash: rbenv: command not found #670

zevski opened this issue Dec 21, 2014 · 22 comments

Comments

@zevski
Copy link

zevski commented Dec 21, 2014

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:

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

@mislav
Copy link
Member

mislav commented Dec 22, 2014

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?

@zevski
Copy link
Author

zevski commented Dec 22, 2014

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.

@mislav
Copy link
Member

mislav commented Dec 22, 2014

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.

@zevski
Copy link
Author

zevski commented Dec 23, 2014

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!

@zevski zevski closed this as completed Dec 23, 2014
@magoo23
Copy link

magoo23 commented Oct 18, 2015

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

@magoo23
Copy link

magoo23 commented Oct 18, 2015

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

@mislav
Copy link
Member

mislav commented Oct 18, 2015

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!

@magoo23
Copy link

magoo23 commented Oct 23, 2015

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

@mislav
Copy link
Member

mislav commented Oct 24, 2015

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.

@benyaminpy
Copy link

benyaminpy commented Jan 23, 2016

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

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?

@mislav
Copy link
Member

mislav commented Jan 23, 2016

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

@eshacker
Copy link

eshacker commented Feb 3, 2016

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

@benyaminpy
Copy link

benyaminpy commented Feb 4, 2016

@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

@roymilder
Copy link

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

@kberube
Copy link

kberube commented May 14, 2016

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

cd
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

@eemartinezsanchez
Copy link

@eshacker Dude Thanks a lot you saved me!!

@IsraelCecil
Copy link

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

@rraimondo
Copy link

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.

@MiladRahmani
Copy link

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

@ghost
Copy link

ghost commented Jan 9, 2019

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

@davham
Copy link

davham commented Jan 16, 2020

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

@shubham-tyagi
Copy link

Running these two commands solved the issue for me.

  • source ~/.bashrc
  • source ~/.bash_profile

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