11
hyperrjas@serv1:~$ rbenv global
1.9.3-p392
hyperrjas@serv1:~$ rbenv local
1.9.3-p392
hyperrjas@serv1:~$ which ruby-build
/usr/local/bin/ruby-build
hyperrjas@serv1:~$ rbenv versions
* 1.9.3-p392 (set by /home/hyperrjas/.ruby-version)
hyperrjas@serv1:~$ rbenv version
1.9.3-p392 (set by /home/hyperrjas/.ruby-version)
hyperrjas@serv1:~$ rbenv rehash
hyperrjas@serv1:~$ ruby -v
-bash: ruby: command not found
hyperrjas@serv1:~$ env | grep PATH
PATH=/home/hyperrjas/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
hyperrjas@serv1:~$ export PATH="$HOME/.rbenv/bin:$PATH"
hyperrjas@serv1:~$ ruby -v
-bash: ruby: command not found

I'm working with ubuntu 12.04.

This is my ~/.profile file:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
eval "$(rbenv init -)"
eval "$(rbenv init -)"

I have installed ruby last version with rbenv and when I try ruby -v I get -bash: ruby: command not found

hyperrjas
  • 10,666
  • 25
  • 99
  • 198
  • I think you need to run a command that adds ruby to your $PATH, unfortunately I have no idea what that command is, good luck! – OneChillDude Apr 04 '13 at 19:17
  • FWIW, you may consider moving toward [RVM](http://rvm.io) – Chris Cashwell Apr 04 '13 at 19:20
  • RVM and rbenv are equally as good. rbenv is lighter weight, and less complicated, with fewer moving parts. RVM has a lot of capabilities, and a lot more things to go wrong. – the Tin Man Apr 04 '13 at 19:23

2 Answers2

11

rbenv needs these at the end of your ~/.bash_profile:

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

Use grep rbenv ~/.bash_profile to see if they're there.

If not, run:

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

and you should be up and running.

See steps 2 and 3 in the docs for more information.

Additional information on .bashrc, .bash_profile and .profile can be found in:

Community
  • 1
  • 1
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • `rbenv init` enables shims and autocompletion. – Stefan Apr 04 '13 at 19:32
  • I don't understand why in rbenv doc specify if you are running ubuntu it is possible add **Ubuntu note**: `Modify your ~/.profile instead of ~/.bash_profile.`. If with `~/.profile` is not working why is specified in doc? – hyperrjas Apr 04 '13 at 19:38
  • Good. I think you'll find rbenv is great for "normal" development. I used RVM for a long time and decided it was getting too big for my needs. – the Tin Man Apr 04 '13 at 19:44
3

Run env | grep PATH and make sure that you have $HOME/.rbenv/bin in your PATH.

If it is not, add this to ~/.bash_profile.

export PATH="$HOME/.rbenv/bin:$PATH"
000
  • 26,951
  • 10
  • 71
  • 101
  • Thank you I have tried with this but I get the same result. This is my `env | grep PATH` `PATH=/home/hyperrjas/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript` Thank you – hyperrjas Apr 04 '13 at 19:19
  • 1
    Open a new terminal window. Your changes will applied at the next terminal window login. – 000 Apr 04 '13 at 19:21