Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv: no such command `init'

Tags:

ruby

rbenv

I installed rbenv according to the instructions at https://github.com/sstephenson/rbenv#section_2

Restarting my shell at point 4 will result in an error

$ rbenv init -
rbenv: no such command `init'

Trying to run the command directly from its folder doesn't work either.

$ cd .rbenv/bin
$ ./rbenv init -
rbenv: no such command `init'

My $PATH

$ echo $PATH
/home/myusername/.rbenv/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/myusername/bin

Running rbenv install works until rbenv rehash is called

$ rbenv install 1.9.3-p0
Downloading http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz...
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /home/hbrandl/.rbenv/versions/1.9.3-p0
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz...
Installing ruby-1.9.3-p0...
Installed ruby-1.9.3-p0 to /home/hbrandl/.rbenv/versions/1.9.3-p0
rbenv: no such command `rehash'

All other rbenv commands don't seem to work.

Any help or pointers greatly appreciated.

like image 266
Hartwig Avatar asked Dec 28 '22 10:12

Hartwig


2 Answers

Check if the symlink is correct:

> ls -l ~/.rbenv/bin/rbenv
lrwxr-xr-x  1 kelvin  staff  16 Mar 29 11:19 /Users/kelvin/.rbenv/bin/rbenv@ -> ../libexec/rbenv

Is your rbenv a symlink to ../libexec/rbenv ? It should be, because it reads that symlink location to know that "libexec" is the location of the other executables.

To fix:

> cd ~/.rbenv/bin
> mv rbenv rbenv.broken
> ln -s ../libexec/rbenv rbenv

It might've broken if you copied the ~/.rbenv from another location, which would probably mess the links up.

like image 73
Kelvin Avatar answered Dec 29 '22 22:12

Kelvin


A working workaround for my problem was to simply add the libexec folder to my path as well.

My rbenv PATH additions now look as follows:

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

This fixes the problem for me.

like image 32
Hartwig Avatar answered Dec 30 '22 00:12

Hartwig