wayneeseguin/rvm — Issue #630: rvm 1.10.0-pre calling non existing after use hooks
Author: pmontrasio
Created: 2011-12-07 09:30:37+00:00
State: open

I got this bug after updating rvm to 1.10.0-pre
I don't have jruby installed and whenever I rvm use something I get these warnings

jruby_options_remove: command not found
jruby_clean_project_options: command not found

That didn't happened with the previous version of rvm.
The culprit is .rvm/hooks/after_use_jruby_opts (don't know why it's there) being called (probably) by .rvm/hooks/after_use
I patched it to check the existence of the hooks.

#!/usr/bin/env bash

. "${rvm_path}/scripts/functions/hooks/jruby"

function_exists () {
declare -f $1 > /dev/null
}

if [[ "${rvm_ruby_string}" =~ "jruby" ]]
then
jruby_options_append "${PROJECT_JRUBY_OPTS[@]}"
else
if function_exists jruby_options_remove; then
jruby_options_remove "${PROJECT_JRUBY_OPTS[@]}"
fi
if function_exists jruby_clean_project_options; then
jruby_clean_project_options
fi
fi

Something along these lines should be applied to all hooks.