Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rbenv not working

Tags:

ruby

rbenv

I installed ruby 2.0 into ~/.rbenv/versions last and now nothing but that is available

$ rbenv versions

system
*ruby-1.9.3-p392 (set by /apps/test_app/.ruby-version)
ruby-2.0.0-p0

$ ruby -v

ruby 2.0.0.p0

$ env | grep PATH

PATH=/home/cbron/.rbenv/shims:/home/cbron/.rbenv/bin

$cat ~/.bash_profile

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

$rbenv global

ruby-1.9.3-p392

$rbenv local

ruby-1.9.3-p392

$rbenv shell

rbenv: no shell-specific version configured

edit: now set the shell, still nothing.

$rbenv shell

ruby-1.9.3-p392

ruby -v still getting

ruby 2.0.0p0

I already sourced my bash_profile, even restarted the computer.

like image 812
cbron Avatar asked Mar 13 '13 18:03

cbron


2 Answers

I had the same issue using zsh and this fixed it:

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

So basically moving the lines from profile to env!

like image 151
tomr Avatar answered Oct 07 '22 10:10

tomr


Extracted from rbenv readme:

rbenv shell

Sets a shell-specific Ruby version by setting the RBENV_VERSION environment variable in your shell. This version overrides application-specific versions and the global version.

$ rbenv shell jruby-1.7.1

When run without a version number, rbenv shell reports the current value of RBENV_VERSION. You can also unset the shell version:

$ rbenv shell --unset

Note that you'll need rbenv's shell integration enabled (step 3 of the installation instructions) in order to use this command. If you prefer not to use shell integration, you may simply set the RBENV_VERSION variable yourself:

$ export RBENV_VERSION=jruby-1.7.1

So in order to use it you need to specify the ruby version as rbenv shell argument (f.e. rbenv shell 2.0.0.p0, or set RBENV_VERSION (f.e. export RBENV_VERSION=2.0.0.p0)

like image 41
mdesantis Avatar answered Oct 07 '22 12:10

mdesantis