sstephenson/rbenv — Issue #149: rbenv init throws a readlink error
Author: dkam
Created: 2011-11-22 05:35:21+00:00
State: open

Hi,
New install of rbenv (after removal of rvm). The 'rbenv init -' command fails

````
dkam@host:~$ rbenv init -
export PATH="/home/dkam//.rbenv/shims:${PATH}"
source "/home/dkam/.rbenv/libexec/../completions/rbenv.bash"
rbenv rehash 2>/dev/null
/bin/readlink: missing operand
Try `/bin/readlink --help' for more information.
function rbenv() {
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi

case "$command" in
shell)
eval `rbenv "sh-$command" "$@"`;;
*)
command rbenv "$command" "$@";;
esac
}
dkam@host:~$ RBENV_DEBUG=1 rbenv init -
+ '[' -z '' ']'
+ RBENV_ROOT=/home/dkam//.rbenv
+ export RBENV_ROOT
+ '[' -z '' ']'
++ pwd
+ RBENV_DIR=/home/dkam/
+ export RBENV_DIR
+ shopt -s nullglob
++ abs_dirname /home/dkam//.rbenv/bin/rbenv
+++ pwd
++ local cwd=/home/dkam/
++ local path=/home/dkam//.rbenv/bin/rbenv
++ '[' -n /home/dkam//.rbenv/bin/rbenv ']'
++ cd /home/dkam//.rbenv/bin
++ local name=rbenv
+++ resolve_link rbenv
++++ type -p greadlink readlink
++++ head -1
+++ /bin/readlink rbenv
++ path=../libexec/rbenv
++ '[' -n ../libexec/rbenv ']'
++ cd ../libexec
++ local name=rbenv
+++ resolve_link rbenv
++++ type -p greadlink readlink
++++ head -1
+++ /bin/readlink rbenv
+++ true
++ path=
++ '[' -n '' ']'
++ pwd
++ cd /home/dkam/
+ bin_path=/home/dkam/.rbenv/libexec
+ export PATH=/home/dkam/.rbenv/libexec:/home/dkam//.rbenv/bin:/home/dkam//.rbenv/shims:/home/dkam//.rbenv/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ PATH=/home/dkam/.rbenv/libexec:/home/dkam//.rbenv/bin:/home/dkam//.rbenv/shims:/home/dkam//.rbenv/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ hook_path=:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d
+ export RBENV_HOOK_PATH=:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d
+ RBENV_HOOK_PATH=:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d
+ shopt -u nullglob
+ command=init
+ case "$command" in
++ command -v rbenv-init
+ command_path=/home/dkam/.rbenv/libexec/rbenv-init
+ '[' -z /home/dkam/.rbenv/libexec/rbenv-init ']'
+ shift 1
+ exec /home/dkam/.rbenv/libexec/rbenv-init -
+ print=
+ '[' - = - ']'
+ print=1
+ shift
+ shell=
+ '[' -z '' ']'
++ basename /bin/bash
+ shell=bash
++ abs_dirname /home/dkam/.rbenv/libexec/rbenv-init
+++ pwd
++ local cwd=/home/dkam/
++ local path=/home/dkam/.rbenv/libexec/rbenv-init
++ '[' -n /home/dkam/.rbenv/libexec/rbenv-init ']'
++ cd /home/dkam/.rbenv/libexec
++ local name=rbenv-init
+++ resolve_link rbenv-init
++++ type -p greadlink readlink
++++ head -1
+++ /bin/readlink rbenv-init
+++ true
++ path=
++ '[' -n '' ']'
++ pwd
++ cd /home/dkam/
+ root=/home/dkam/.rbenv/libexec/..
+ '[' -z 1 ']'
+ mkdir -p /home/dkam//.rbenv/shims /home/dkam//.rbenv/versions
+ echo 'export PATH="/home/dkam//.rbenv/shims:${PATH}"'
export PATH="/home/dkam//.rbenv/shims:${PATH}"
+ case "$shell" in
+ echo 'source "/home/dkam/.rbenv/libexec/../completions/rbenv.bash"'
source "/home/dkam/.rbenv/libexec/../completions/rbenv.bash"
+ echo 'rbenv rehash 2>/dev/null'
rbenv rehash 2>/dev/null
+ commands=(`rbenv commands --sh`)
++ rbenv commands --sh
+ '[' -z /home/dkam//.rbenv ']'
+ RBENV_ROOT=/home/dkam//.rbenv
+ export RBENV_ROOT
+ '[' -z /home/dkam/ ']'
++ abs_dirname /home/dkam/
+++ pwd
++ local cwd=/home/dkam/
++ local path=/home/dkam/
++ '[' -n /home/dkam/ ']'
++ cd /home/dkam
++ local name=
+++ resolve_link ''
++++ type -p greadlink readlink
++++ head -1
+++ /bin/readlink
/bin/readlink: missing operand
Try `/bin/readlink --help' for more information.
+++ true
++ path=
++ '[' -n '' ']'
++ pwd
++ cd /home/dkam/
+ RBENV_DIR=/home/dkam
+ export RBENV_DIR
+ shopt -s nullglob
++ abs_dirname /home/dkam/.rbenv/libexec/rbenv
+++ pwd
++ local cwd=/home/dkam/
++ local path=/home/dkam/.rbenv/libexec/rbenv
++ '[' -n /home/dkam/.rbenv/libexec/rbenv ']'
++ cd /home/dkam/.rbenv/libexec
++ local name=rbenv
+++ resolve_link rbenv
++++ type -p greadlink readlink
++++ head -1
+++ /bin/readlink rbenv
+++ true
++ path=
++ '[' -n '' ']'
++ pwd
++ cd /home/dkam/
+ bin_path=/home/dkam/.rbenv/libexec
+ export PATH=/home/dkam/.rbenv/libexec:/home/dkam/.rbenv/libexec:/home/dkam//.rbenv/bin:/home/dkam//.rbenv/shims:/home/dkam//.rbenv/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ PATH=/home/dkam/.rbenv/libexec:/home/dkam/.rbenv/libexec:/home/dkam//.rbenv/bin:/home/dkam//.rbenv/shims:/home/dkam//.rbenv/bin::/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ hook_path=:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d
+ export RBENV_HOOK_PATH=:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d
+ RBENV_HOOK_PATH=:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d:/home/dkam//.rbenv/rbenv.d:/usr/local/etc/rbenv.d:/etc/rbenv.d
+ shopt -u nullglob
+ command=commands
+ case "$command" in
++ command -v rbenv-commands
+ command_path=/home/dkam/.rbenv/libexec/rbenv-commands
+ '[' -z /home/dkam/.rbenv/libexec/rbenv-commands ']'
+ shift 1
+ exec /home/dkam/.rbenv/libexec/rbenv-commands --sh
+ '[' --sh = --complete ']'
+ '[' --sh = --sh ']'
+ sh=1
+ shift
+ shopt -s nullglob
+ for path in '${PATH//:/'\''
+ sort
'\''}'
+ for command in '"${path}/rbenv-"*'
+ uniq
+ command=commands
+ '[' -n 1 ']'
+ '[' com = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=completions
+ '[' -n 1 ']'
+ '[' com = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=exec
+ '[' -n 1 ']'
+ '[' exe = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=global
+ '[' -n 1 ']'
+ '[' glo = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=help
+ '[' -n 1 ']'
+ '[' hel = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=hooks
+ '[' -n 1 ']'
+ '[' hoo = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=init
+ '[' -n 1 ']'
+ '[' ini = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=local
+ '[' -n 1 ']'
+ '[' loc = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=prefix
+ '[' -n 1 ']'
+ '[' pre = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=rehash
+ '[' -n 1 ']'
+ '[' reh = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=root
+ '[' -n 1 ']'
+ '[' roo = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=set-default
+ '[' -n 1 ']'
+ '[' set = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=set-local
+ '[' -n 1 ']'
+ '[' set = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=shims
+ '[' -n 1 ']'
+ '[' shi = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=sh-shell
+ '[' -n 1 ']'
+ '[' sh- = sh- ']'
+ echo shell
+ for command in '"${path}/rbenv-"*'
+ command=version
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-file
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-file-read
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-file-write
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-name
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-origin
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=versions
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=whence
+ '[' -n 1 ']'
+ '[' whe = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=which
+ '[' -n 1 ']'
+ '[' whi = sh- ']'
+ for path in '${PATH//:/'\''
'\''}'
+ for command in '"${path}/rbenv-"*'
+ command=commands
+ '[' -n 1 ']'
+ '[' com = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=completions
+ '[' -n 1 ']'
+ '[' com = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=exec
+ '[' -n 1 ']'
+ '[' exe = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=global
+ '[' -n 1 ']'
+ '[' glo = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=help
+ '[' -n 1 ']'
+ '[' hel = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=hooks
+ '[' -n 1 ']'
+ '[' hoo = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=init
+ '[' -n 1 ']'
+ '[' ini = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=local
+ '[' -n 1 ']'
+ '[' loc = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=prefix
+ '[' -n 1 ']'
+ '[' pre = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=rehash
+ '[' -n 1 ']'
+ '[' reh = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=root
+ '[' -n 1 ']'
+ '[' roo = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=set-default
+ '[' -n 1 ']'
+ '[' set = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=set-local
+ '[' -n 1 ']'
+ '[' set = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=shims
+ '[' -n 1 ']'
+ '[' shi = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=sh-shell
+ '[' -n 1 ']'
+ '[' sh- = sh- ']'
+ echo shell
+ for command in '"${path}/rbenv-"*'
+ command=version
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-file
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-file-read
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-file-write
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-name
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=version-origin
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=versions
+ '[' -n 1 ']'
+ '[' ver = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=whence
+ '[' -n 1 ']'
+ '[' whe = sh- ']'
+ for command in '"${path}/rbenv-"*'
+ command=which
+ '[' -n 1 ']'
+ '[' whi = sh- ']'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for command in '"${path}/rbenv-"*'
+ command=install
+ '[' -n 1 ']'
+ '[' ins = sh- ']'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ for path in '${PATH//:/'\''
'\''}'
+ IFS='|'
+ cat
function rbenv() {
command="$1"
if [ "$#" -gt 0 ]; then
shift
fi

case "$command" in
shell)
eval `rbenv "sh-$command" "$@"`;;
*)
command rbenv "$command" "$@";;
esac
}
````

The gem command also rails - but I'm guessing that's because the environment isn't setup due to the failure of init:

````
dkam@host:/home/dkam$ gem install bundler
/home/dkam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/config_file.rb:28:in `': uninitialized constant Gem::ConfigFile (NameError)
from /home/dkam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dkam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dkam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:9:in `'
from /home/dkam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dkam/.rbenv/versions/1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/dkam//.rbenv/versions/1.9.2-p180/bin/gem:9:in `

'
dkam@host:/home/dkam$ which gem
/home/dkam//.rbenv/shims/gem
````