Syntax error running rbenv init #454

Closed
steakchaser opened this Issue Sep 28, 2013 · 1 comment

2 participants

@steakchaser

I'm installing rbenv from a capistrano recipe (ruby 1.9.3-p125, bootstrap-ubuntu-12-04). Recipe has been working great for the past 3 months and as recent as yesterday. Starting today, I get the following error from this step run %q{eval "$(rbenv init -)"}

  • executing "eval \"$(rbenv init -)\"" servers: ["ip_removed"] [ip_removed] executing command ** [out :: ip_removed] sh: 2: /home/deployer/.rbenv/libexec/../completions/rbenv.bash: ** [out :: ip_removed] Syntax error: "(" unexpected (expecting "}") ** [out :: ip_removed] command finished in 427ms failed: "sh -c 'eval \"$(rbenv init -)\"'" on ip_removed

From what I can tell, servers that I built a few months ago have a different version of rbenv.bash

Old:

rbenv() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"

  if [ "$COMP_CWORD" -eq 1 ]; then
    COMPREPLY=( $(compgen -W "$(rbenv commands)" -- "$word") )
  else
    local command="${COMP_WORDS[1]}"
    local completions="$(rbenv completions "$command")"
    COMPREPLY=( $(compgen -W "$completions" -- "$word") )
  fi
}

complete -F _rbenv rbenv

New:

rbenv() {
  COMPREPLY=()
  local word="${COMP_WORDS[COMP_CWORD]}"

  if [ "$COMP_CWORD" -eq 1 ]; then
    COMPREPLY=( $(compgen -W "$(rbenv commands)" -- "$word") )
  else
    local words=("${COMP_WORDS[@]}")
    unset words[0]
    unset words[$COMP_CWORD]
    local completions=$(rbenv completions "${words[@]}")
    COMPREPLY=( $(compgen -W "$completions" -- "$word") )
  fi
}

complete -F _rbenv rbenv
@mislav

Why are you running rbenv init - in Capistrano environment? Since it's a non-interactive shell, you don't need the rbenv() shell function in there nor shell completions. The only thing you need to get rbenv working is add its shims to PATH. See #446

@mislav mislav closed this Sep 29, 2013
@chulkilee chulkilee referenced this issue in RiotGamesCookbooks/rbenv-cookbook Dec 22, 2013
Open

Syntax error on rbenv_execute #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment